1

Can anybody explain how NHibernate behave in case of:

  1. Insert
  2. Update
  3. Delete

in case if Parent/Child collection with inverss - non inverse , cascadea ll, cascade all delete orphan.

i want to know the rules that follow to execute each case of the above.

Thanks in advance

1 Answers1

2

Try look here:

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

or here:

Nhibernate Cascade

also here:

NHibernate Definitive Cascade application guide

update

Here you can find a great explanation of inverse:

Inverse Attribute in NHibernate

And those are cascade differences:

  1. cascade="none", the default, tells Hibernate to ignore the association.
  2. cascade="save-update" tells Hibernate to navigate the association when the transaction is committed and when an object is passed to save() or update() and save newly instantiated transient instances and persist changes to detached instances.
  3. cascade="delete" tells Hibernate to navigate the association and delete persistent instances when an object is passed to delete().
  4. cascade="all" means to cascade both save-update and delete, as well as calls to evict and lock.
  5. cascade="all-delete-orphan" means the same as cascade="all" but, in addition, Hibernate deletes any persistent entity instance that has been removed (dereferenced) from the association (for example, from a collection).
  6. cascade="delete-orphan" Hibernate will delete any persistent entity instance that has been removed (dereferenced) from the association (for example, from a collection).
Community
  • 1
  • 1
danyolgiax
  • 12,798
  • 10
  • 65
  • 116
  • Thank you Danyolgiax for your links, But i am looking for some knowledge about how NHibernate take decisions to execute sql statements and how it think to arrange it. For example in case of we have a one-to-many relationship or parent/child collection what will be the case if we map that with inverse or not and with Cascade All, CascadeAllDeleteOrphan or without cascade what the decision Nhibernate will take in each case and what the generated sql statement orders. Thanks – Mohammed Wafy Jul 16 '11 at 08:10
  • Please cite your sources for the cascade differences. They appear to be from Hibernate in Action. – fgb Jun 06 '14 at 14:28
  • @fgb I found it googling – danyolgiax Jun 06 '14 at 14:46