-->
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: inverse attribute - Too confusing !!!
PostPosted: Fri Aug 24, 2007 6:46 am 
Beginner
Beginner

Joined: Wed Aug 22, 2007 5:53 am
Posts: 38
If we have a bidirectional association - we need to make one end of the association as inverse.

Consider example of Item - Bid bidirectional association where
From Item to Bid it's one-to-many association
From Bid to Item it's many-to-one association

In Hibernate_Reference : It's mentioned as :
All bi-directional associations need one side as inverse. In a one-to-many association it has to be the many-side.

According to this, the inverse attribute should be @ Bid side. This means we need to specify inverse attribute in Bid.hbm.xml file.

BUT (NOTE THE CONTRADICTION)

In Hibernate In Action Book, it's written in Item.hbm.xml as :
Code:
<class
name="Item"
table="ITEM">
...
<set
name="bids"
inverse="true">
<key column="ITEM_ID"/>
<one-to-many class="Bid"/>
</set>
</class>


The following are few more related questions :
1. When we say many side of association (Bid) do we mean/refer to Bid.hbm.xml ?

2. Does this mean that, if i specify the inverse attribute in Item.hbm.xml (i.e Item Side [One Side of association]), it means ignore the changes made @ item say. Hence if we only call item.getBids().add(bid), no changes
will be made persistent. Instead we are telling Hibernate that it should propagate changes made at the Bid end of the association to the database. i.e when we call bid1.setItem(item) ,it should become persistent ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 24, 2007 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
According to this, the inverse attribute should be @ Bid side.


No, the "many" side is the one with "many" references.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.