NHibernate disable all-delete-orphan
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
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.
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.
精彩评论