| Author |
delete option of cascade in Hibernate one-to-one association
|
Soumya Ranjan Mohanty
Ranch Hand
Joined: Mar 07, 2010
Posts: 44
|
|
I am not able to delete the corresponding one-to-one relation row using delete option of cascade. Here are the code for my class and Mappings.
Code For Employee.java Class.
Code for PersonalDetails.java Class
mapping -- Employee.hbm.xml
mapping- PersonalDetails.hbm.xml
When i delete any row from Employee table the Corresponding Foreign key row in PersonalDetails Table is not deleting. Please Help Me.
Thanks
|
 |
joy b chakravarty
Ranch Hand
Joined: May 16, 2011
Posts: 62
|
|
Interesting.. Not exactly sure why this one-to-one bidirectional relation is giving you trouble.
Can you try removing this
<generator class="foreign">
<param name="property">personalDetails</param>
</generator>
and instead have the following in the mapping- PersonalDetails.hbm.xml
<generator class="foreign">
<param name="property">emp</param>
</generator>
|
Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both
|
 |
Soumya Ranjan Mohanty
Ranch Hand
Joined: Mar 07, 2010
Posts: 44
|
|
i did exactly what you said and it's working fine. Thanks a lot joy b chakravarty .Can you please explain what was the mistake so that i can clear my doubt.
Again Thanks a lot.
|
 |
joy b chakravarty
Ranch Hand
Joined: May 16, 2011
Posts: 62
|
|
In a relationship, there is an owning side, here what you wanted is Employee as the owing side.
with your earlier configuration PersonalDetails became the owing side as the PersonalDetails 'eno' was assigned to an employee which shouldn't have been the case.
reversing that made Employee the owing side. Hope this helps.
|
 |
 |
|
|
subject: delete option of cascade in Hibernate one-to-one association
|
|
|