-->
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.  [ 4 posts ] 
Author Message
 Post subject: Associations
PostPosted: Sun Oct 26, 2003 1:04 pm 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Given class Foo and Bar. Is having a many-to-many in one equivalent to having many-to-one in both? I find the latter one easier to cope with.


Top
 Profile  
 
 Post subject: nope
PostPosted: Sun Oct 26, 2003 2:51 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
definitely not! these are totally different situations. using only many-to-one mappings you can only get access to one related entity. you need a many-to-many or one-to-many to get a related collection of entities.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 3:23 am 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Is many-to-many in one equivalent to having one-to-many in both, then?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 12:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nickvajberg wrote:
Is many-to-many in one equivalent to having one-to-many in both, then?


Many-to-many cannot be equivalent to one-to-many because even if relation cannot be navigated, you can access to relation via HQL

So having a (A) one-to-many (B) (and many-to-one on the other side) means that for 1 A there are many B AND for 1 B there is only one A

So having a one-to-many (or many-to-one) both side will lead to one-to-one or inconsistence.

The equivalent of many-to-many can be done by A one-to-many AB many-to-one B, but you need an AB object.

_________________
Emmanuel


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