-->
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: Mulitple Foreign Keys
PostPosted: Wed Mar 30, 2005 12:19 pm 
Newbie

Joined: Mon Jan 12, 2004 11:59 am
Posts: 13
Location: USA
Hi All:

If I have TABLE_A, TABLE_B and TABLE_C and TABLE_C has a foreign key that is associated with TABLE_A and another foreign key associated with TABLE_B how can I show the relationship in the hibernate.xml file.

In other words, TABLE_C is a child of both TABLE_A and TABLE_B.

Can I use the many-to-many relationship?

Thank you in advance,
Om


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 30, 2005 2:37 pm 
Regular
Regular

Joined: Thu Apr 15, 2004 1:12 pm
Posts: 55
Hi Om,

If your TABLE_C is an association table — i.e., it exists in order to impleement a relationship between A and B — then yes, that corresponds to a many-to-many association in Hibernate. But it doesn't sound like that is the case, because you said that "C is a child of both A and B". An association table would be used to implement a many-to-many association between A to B, i.e., "a B may be a child of many A's".

Terms like "many-to-many" refer to the ordinalites of the two ends of the relationship. It has nothing to do with how many objects a relationship participates in.

Beyond that, I can't tell you exactly how to map your classes, because I don't know (a) the howmany-to-howmany of the relationships, and (b) your navigability requirements (bidirectional? Or unidirectional, and if so from which end?) and (c) the collection semantics you require for each (Set? List?)

Is this a legacy RDB schema you have to code to? If not, I'd strongly recommend you drive this from the Java end and work your way down to the hibernate mappings, developing the schema as necessary to support the mappings.


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.