Hibernate Parent/Child


General J2EE: Hibernate Parent/Child

  1. Hibernate Parent/Child (2 messages)

    I have two tables: first table contains course,unit,lesson details. second table contains many-to-one relationship between course and units. It means a course contains many units and a unit contains many lessons. First Table: Id contentName contentType 1 course1 course 2 lesson1 lesson 3 lesson2 lesson 4 unit1 unit 5 unit2 unit Second Table: contenId refId 2 1 3 1 4 2 5 2 For this scenario, how to write hbm file and mapping java class files. Any help would be greatly appreciated.

    Threaded Messages (2)

  2. Re: Hibernate Parent/Child[ Go to top ]

  3. use [ Go to top ]

    Since you have only one table storing three different classes, I would suggest that you make use of the feature of hibernate. e.g. select * from first_table where contentType='lesson' ... this will give you what appears to be three different tables - one for each concept/class. then, you use use the documentation at hibernate.org to create a one-to-many relationship between courses and units.