Loading
inverse attribute in Hibernate

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is the importance of "inverse" attribute in Hibernate? How would you inform hibernate which end of relation should be ignored?


Ans)

Essentially "inverse" indicates which end of a relationship should be ignored, so when
persisting a parent who has a collection of children, should you ask the parent for its
list of children, or ask the children who the parents are ?

Here is how you set this parameter in a <many-to-one> relation.
Child :
<hibernate–mapping>
<class name="Child" table="child">
 <many–to–one name="parent"
                 class="Parent"
                 column="parent_id"/>
</class>
</hibernate–mapping>
 

Parent :
<hibernate–mapping>
<class name="Child" table="child">
<bag name="children" inverse="true" cascade="save–update">
      <key column="parent_id"/>
      <one–to–many class="Child"/>
    </bag>
</class>
</hibernate–mapping>



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

inverse attribute in Hibernate


inverse attribute in Hibernate

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free