-->
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.  [ 1 post ] 
Author Message
 Post subject: *** inverse="true" exact usecase
PostPosted: Mon Sep 01, 2008 11:42 am 
Newbie

Joined: Tue Jun 10, 2008 12:39 pm
Posts: 14
Hi,

I have an Account and Detail tables with one-to-many association.

Table 1:

Name : Account
Columns: account_id
account_name

Table 2:

Name: Detail
Columns : detail_id
detail_name

1) Account is having a SET to maintain Details.Detail will be having a reference to Account.I can get the set of Details from Account object.,from the other side I will be getting account object for every Detail Object.

2)In the Account.hbm.xml files :

<set name="detail" cascade="all" lazy="false">
<key column="account_id" not-null="true"/>
<one-to-many class="Detail"/>
</set>

In the Detail.hbm.xml files.

<many-to-one name="account" column="account_id”
class="account" not-null="true" lazy="false" />


3) According to many articles, here I should go for Bi-directional association and make
<many-to-one> inverse=”true”.I should update on bothsides account.setDetails(<set>Detail) and Detail.setAccount(account)

I am not doing the above, still I am able to satisfy the requirement.

Queries :

1) Can u please explain me the use of birectional association instead of going in my way as two unidirectional (one-to-many and many-to-one) associations.

2) I am not updating the both sides of the association at any time.Can u please tell me what is the requirement to do so?

Thanks
Babu

_________________
Thanks
Babu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.