Pregunta

Lets say i have a table called Parent with 5 rows of Children info in database.

If i'm in application layer remove all childs in in parent's list and add a new child that doesnt exist in db and then run SaveOrUpdate, will the existing children in table be deleted or will it just add the non-existing child to the table ?

EDIT: I got Cascade.ALL and but not delete orphan in my mapping.

¿Fue útil?

Solución

If you use cascade all the child items are only deleted if you delete the parent. If you remove children and reset their parent property to null however these child records are only updated with null parent reference but not deleted from the database.

You can find explanation and examples in the nhibernate documentation (Chapter 21.3. Cascading lifecycle).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top