Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between delete and orphan-delete

 
Pradeep Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
In hibernate we have two options for deleting the child. delete and delete-orphan. eg: the below code



What is the difference between the two.

Regards,
Pradeep
 
Vijitha Kumara
Bartender
Posts: 3953
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quoted from the Reference:
A special cascade style, delete-orphan, applies only to one-to-many associations, and indicates that the delete() operation should be applied to any child object that is removed from the association.



 
Pradeep Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
But in <one-to-many> tag there is no cascade attribute. . Is it in the <set> tag we need to mention the cascading behavior for the collection(Set) for <one-to-many> relationship?

Eg:

 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!