0
votes

Application use NHibernate. I Have object A that contains set of objects B. I have cascade="all-delete-orphan" in my config file. When I do changes in A object, then save, object B is also saving. How to prevent saving B ? Is it possible to disable cascade for a moment ? regards Marcin

2

2 Answers

1
votes

You may consider using IStatlessSession

Operations performed using a stateless session do not ever cascade to associated instances. Collections are ignored by a stateless session. Operations performed via a stateless session bypass Hibernate's event model and interceptors. Stateless sessions are vulnerable to data aliasing effects, due to the lack of a first-level cache. A stateless session is a lower-level abstraction, much closer to the underlying ADO.

0
votes

To prevent cascade saving, you have to remove the attribute from the mapping. As mappings are built into session factory, there is no simple way to disable cascade temporarily.