-->
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: What happen when I put "inverse=true" in the child
PostPosted: Fri May 23, 2008 2:42 am 
Newbie

Joined: Fri May 02, 2008 1:25 am
Posts: 7
What happend when I will write "inverse=true" in the child class mapping instead of parent class mapping.

For example:
An organization have many employee and the mapping file contains following mapping:

1. Employee.hbm contains:

<many-to-one name="organization" insert="true" update="true" inverse=true column="ORG_ID" lazy="false" fetch="join" class="Organization" not-null="true"/>

2. Organization.hbm contains:

<set name="employees" lazy="false" fetch="join" table="employee" cascade="all">
<key column="ORG_ID"/>
<one-to-many class="Employee" />
</set>

Thanks in advance

Umashankar.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 23, 2008 7:18 am 
Newbie

Joined: Wed Sep 06, 2006 6:08 am
Posts: 11
Location: Rome, Italy
From the Hibernate manual:

"What about the inverse mapping attribute? For you, and for Java, a bi-directional link is simply a matter of setting the references on both sides correctly. Hibernate however doesn't have enough information to correctly arrange SQL INSERT and UPDATE statements (to avoid constraint violations), and needs some help to handle bidirectional
associations properly. Making one side of the association inverse tells Hibernate to basically ignore it, to consider it a mirror of the other side. That's all that is necessary for Hibernate to work out all of the issues
when transformation a directional navigation model to a SQL database schema.
The rules you have to remember are straightforward: All bi-directional associations need one side as inverse. In a one-to-many association it has to be the many-side, in many-to-many association you can pick either side, there is no difference."

Ken


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.