-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Parent/Child problem
PostPosted: Mon Sep 04, 2006 9:32 am 
Newbie

Joined: Mon Sep 04, 2006 9:26 am
Posts: 2
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 content content
Name Type
1 course1 course
2 lesson1 lesson
3 lesson2 lesson
4 unit1 unit
5 unit2 unit

Second Table:

Id 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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 04, 2006 3:54 pm 
Newbie

Joined: Mon Sep 04, 2006 12:24 pm
Posts: 1
Although you mentioned parent/child and one-to-many relationships, this looks like a regular many-to-many relationship.

The mapping would be something like:

Code:
<set name="units" lazy="true" table="table2">
            <key column="courseId"/>
            <many-to-many class="Unit" column="unitId"/>
</set>


Have a look at the online documentation, they have many examples.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.