-->
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: Bidirectional One-to-many
PostPosted: Thu Apr 12, 2007 8:21 am 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
Hi Sir,

In Hibernate Annotations 3.3.0 GA Reference Guide (page 20), there's the following:

"Troop has a bidirectional one to many relationship with Soldier through the troop property. You don't have to
(must not) define any physical mapping in the mappedBy side.

To map a bidirectional one to many, with the one-to-many side as the owning side, you have to remove the
mappedBy element and set the many to one @JoinColumn as insertable and updatable to false. This solution is
obviously not optimized and will produce some additional UPDATE statements."

Can anyone comment if the mentioned solution is not optimized, what will be the optimize solution?

Please advise.

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 5:50 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
the optimal solution is to use the previous mapping (ie with mappedBy)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 8:38 pm 
Regular
Regular

Joined: Wed Apr 12, 2006 12:49 am
Posts: 105
Location: Malaysia
But why the documentation put it as "You don't have to
(must not) define any physical mapping in the mappedBy side. "

Sounds like we should not use "mappedby" but your advice is using mappedby is the optimum solution.

I'm confuse, do you mind to clarify further?

_________________
Thank you.

Regards,
Jap.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 16, 2007 2:23 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
physycal mapping == @JoinTable or @JoinColumn
mappedBy is a logical mapping

_________________
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.