NHibernate Cascade Options Explained

by Matt 30. March 2010 00:23

NHibernate offers several cascading options.  Consider the behaviour of each, and choose the best option for your app.

  • delete – If an object is deleted, delete all associated objects.
  • delete-orphans – If an object is deleted, delete all objects associated to it.  Also when an object is no longer associated with another object, delete it.
  • all-delete-orhpans - If an object is saved, deleted, or updated, check associated objects and save, delete, or update them.  Also when an object is no longer associated with another object, delete it.
  • save-update – When an object is saved or updated, save or update any associated objects that are now dirty
  • all – If an object is saved, deleted, or updated, check related objects and save, delete, or update them
  • none – Let’s developers handle cascades by themselves.
Categories: NHibernate