3 Replies Latest reply on Feb 11, 2008 2:28 AM by nickarls

    JBoss Seam DVDStore Example- Hibernate Mapping Question for

    bloreguy

      I am a newbie into Seam/Hibernate world and very much impressed with the technologies. HAd a simple question on Hibernate mapping and would very much appreciate response.

      In the dvdstore example in Jboss Seam examples, the hibernate.cfg.xml does not have any *.hbm.xml for the entity classes and also does not have any mapping class entries. I was under the impression that 1 of them has to be present in the hibernate.cfg.xml file. Why is this not so? How are the entity classes mapped into the corresponding tables in the database? Is any other file apart from hibernate.cfg.xml used? Or is the schema auto-discovered bu Hibernate based on the annotations in the Java Entity classes?

      Any help deeply appreciated.

      Thanks

        • 1. Re: JBoss Seam DVDStore Example- Hibernate Mapping Question
          nickarls

          The entities have JPA annotations that describe the mapping between objects and database tables and hibernates serves as the underlying implementation. The annotations are scanned automagically

          There are plenty of JPA beginner tutorials around.

          • 2. Re: JBoss Seam DVDStore Example- Hibernate Mapping Question
            bloreguy

            Thank you very much. WHere do I specify that the JPA annotated classes have to be loaded automatically? I used the entry
            property name="hibernate.archive.autodetection" value="class, hbm" and still see that when I refer to an entity class, it gives me an exception that the entity class is not mapped.

            When I add an entry mapping class in hibernate.cfg.xml, the error disappears.
            Also, I see that the dvdstore demo does not use any entry to autodetect the schema and this is where I missed the link.

            Thanks again

            • 3. Re: JBoss Seam DVDStore Example- Hibernate Mapping Question
              nickarls

              Use eclipse + jboss tools to generate a sample project and move on from there.

              You shouldn't have to do anything extra, I think the classes just have to be found by the same classloader that picks up your persistence.xml(?)