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
|