NHibernate auditing in disconnected mode

Posted by Ciaran on Stack Overflow See other posts from Stack Overflow or by Ciaran
Published on 2010-05-19T23:42:44Z Indexed on 2010/05/19 23:50 UTC
Read the original article Hit count: 216

I'm developing an app with a Silverlight UI, transferring my domain objects over WCF and persisting them via NHibernate. I'm therefore working with NHibernate in a disconnected mode.

I'm already using the NHibernate PreUpdate and PreInsert EventListeners to perform some metadata operations (updating Create/Update date, created/updated by etc) and they are working fine.

I now have a requirement to perform data logging on some of my domain objects. So I will need to have an audit table that has a before-save and after-save state of certain entities.

I had wanted to use the @event.Persister.OldState and @event.Persister.NewState to perform this logging, but because I am in a disconnected scenario (using different Sessions from when data is retrieved to when it is persisted), @event.Persister.OldState is null when I am saving my changes back to the database.

How is anyone else doing data logging in a disconnected scenario with NHibernate?

© Stack Overflow or respective owner

Related posts about nhibernate

Related posts about auditing