Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nhibernate Cascade

Tags:

What does Cascade in Nhibernate mean?

I see a lot of options in cascading:

  • Delete
  • All
  • AllDeleteOrphan
  • DeleteOrphan
  • SaveUpdate

Can you explain these with with examples and their distinctions?

like image 977
Quintin Par Avatar asked Jan 03 '10 09:01

Quintin Par


People also ask

What is Cascade all Delete Orphan?

delete − it will cascade deletes. all-delete-orphan − it is a special one which is quite frequently used and is the same as All Except, if it finds Delete-orphan rows, it will delete those as well.


1 Answers

It means apply the action to an item's related items.

Please see: NHibernate Cascades: the different between all, all-delete-orphans and save-update:

  • none - do not do any cascades, let users handle them by themselves.

  • save-update - when the object is saved/updated, check the associations and save/update any object that requires it (including save/update the associations in many-to-many scenario).

  • delete - when the object is deleted, delete all the objects in the association.

  • delete-orphan - when the object is deleted, delete all the objects in the association. In addition, when an object is removed from the association and not associated with another object (orphaned), also delete it.

  • all - when an object is save/update/delete, check the associations and save/update/delete all the objects found.

  • all-delete-orphan - when an object is save/update/delete, check the associations and save/update/delete all the objects found. In additional to that, when an object is removed from the association and not associated with another object (orphaned), also delete it.

like image 97
Mitch Wheat Avatar answered Oct 24 '22 14:10

Mitch Wheat