• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

delete option of cascade in Hibernate one-to-one association

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 62
Hibernate Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Soumya Ranjan Mohanty
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 62
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
this is supposed to be a surprise, but it smells like a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic