Reputation: 81
I need to save a unchanged object via nhibernate to get a database trigger fired.
So how can I tell nhibernate that this object is dirty even if no property has changed?
Upvotes: 3
Views: 2093
Reputation: 81
So in respect to my comment to Radims answer I did the following:
I changed one entry of the loadedstate array of the entity so nhibernate will see it as changed on next save.
I know that this is a bit of a workaround but for me it works so far.
EntityEntry entry = sessImpl.PersistenceContext.GetEntry(dbo);
entry.LoadedState[x] = y;
Upvotes: 4
Reputation: 123861
There are NHibernate extension points, exactly for this scenario. In this case, we can append custom EventListener
or introduce an IInterceptor
.
Check this question How to make NHibernate considered property to always be dirty when using dynamic update or insert? for a solution (answer based on IInterceptor)
See the NHibernate documenation 12. Interceptors and events
Upvotes: 4