-->
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: Mapping many-to-many relationships from a common attribute
PostPosted: Fri Oct 07, 2005 4:43 am 
Newbie

Joined: Fri Oct 07, 2005 4:26 am
Posts: 1
I have two sets of data types and associated tables: brother's and sisters. Each data type has a parent id and contains a collection of siblings of the opposite gender. Therefore, there is a many-to-many relationship between the brothers and sisters. This relationship is based on them sharing a common parentId attribute -- i.e. I am not using a join table

I have read through the documentation and examples. All many-to-many associations that I have come across in hibernate require a join table in order to complete the many-to-many mapping. However, I do not want to maintain these relationships in a seperate join table. All of the information required for forming the relationship is in the shared parentId. I would like to have the ability to query and initialize collections of the associated siblings by using the commonParentId.

Is there a simple way to map a many-to-many relationship based on a common attribute without requiring a join table?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 10, 2005 11:18 am 
Regular
Regular

Joined: Sat Aug 28, 2004 4:15 pm
Posts: 61
Wow, your post is quite bold

It seems to me that since you have a parentId in each these that you probably have a PARENT table. This means the parent table IS the join table. In that sense, the parent has a one-to-many on each type of child. Then you can derive the many-to-many you discussed by accessing their parent.

Now, the problem with what I just mentioned is that only one parent can exist so you'll have to work with that a bit.

_________________
Joe W


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.