-->
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.  [ 3 posts ] 
Author Message
 Post subject: many to many relation
PostPosted: Sat Jul 10, 2010 7:33 am 
Newbie

Joined: Tue Jul 06, 2010 11:37 am
Posts: 6
many-to-many relation:
----------------------

i have table A, table B , link table or reference table C

Table A Table C Table B
AId AId BId
AName BId BName

as table c is link table it contains the two foreign keys(AId,BId)........

as this relation is many-to-many the mapping file for TableA ie A.hbm.xml is

<class name="A" table="A"....>
<set name="bset" table="C">
<key column="AId"/>
<many-to-many column="BId" class="B"/>
</set>
</class>

as this is the way to do for many to many relation............

my silly doubt is if i write a set using one-to-many association in A.hbm.xml to C(AId) and set using one-to-many association in B.hbm.xml to C(BId)..............i can run this hbm's in hibernate,running good and fetching me exact results.

can i say that one-to-many from one side and one-to-many from other side ====== many-to-many relation? is this correct???

please reply with your suggestions........

Thanks,
M.Rakesh


Top
 Profile  
 
 Post subject: Re: many to many relation
PostPosted: Sat Jul 10, 2010 11:10 am 
Newbie

Joined: Tue Jun 29, 2010 2:14 am
Posts: 8
That is correct OTM and OTM create MTM )
The only question is - do you want to manage the MTM table by yourself or you want to forget about it and pass a control to hibernate


Top
 Profile  
 
 Post subject: Re: many to many relation
PostPosted: Sat Jul 10, 2010 1:58 pm 
Newbie

Joined: Thu Jul 08, 2010 8:45 pm
Posts: 3
^

But what if the many-to-many relationship table has columns other than just the keys from the one tables? So in this case it would be table c(AId,BId, mycolumn). How do I map mycolumn with the many to many mapping of hibernate?

I posted this question a couple of days here - viewtopic.php?f=1&t=1005707


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.