-->
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: One-to-many relationship: Unidirectional vs Bidirectional
PostPosted: Thu Jun 07, 2007 3:43 am 
Newbie

Joined: Thu Jun 07, 2007 3:32 am
Posts: 1
In my understanding, it seems that bidirectional one-to-many relationship is a 'super-set' of the unidirectional one.
Moreover, it is better in performance and it allows navigation from both sides.

Then, when will we use unidirectional one? What are the advantages of using it?


Top
 Profile  
 
 Post subject: Re: One-to-many relationship: Unidirectional vs Bidirectional
PostPosted: Thu Mar 03, 2011 10:11 pm 
Newbie

Joined: Sat Jan 27, 2007 2:03 pm
Posts: 6
Location: Dallas, TX - USA
I also have the same question:

Why should I use unidirectional @OneToMany relationships when the corresponding bi-directional relationships seem to perform better? In fact, that is what chapter 23 (Example: Parent/Child) of Hibernate manual says; that is, bidirectional uses less SQL statements during updates. In addition, with a bi-directional we can benefit from the Cascade operations.

On the other hand, if I use unidirectional @OneToMany relationship Hibernate "hbm2ddl" (hibernate3-maven-plugin) ends up generating a join table which makes the DB schemas more complex. Because now we have extra join-tables to manage, making eventual future migrations of data harder, since we have to account for the join tables as well as the two other tables.

Again, why should I use a unidirectional one-to-many relationship instead of the bidirectional one-to-many ?

Thanks,

Rubens.

_________________
--
Rubens Gomes
www.rubens-gomes.com


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.