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?
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?
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
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;