Is there a way to track only object deletes in NHibernate Envers?

49 Views Asked by At

I'd like to configure NHibernate Envers so that only object deletes are audited. Is it possible?

1

There are 1 best solutions below

0
Roger On

I guess you can derive from AuditEventListener and override OnPostInsert, OnPostRecreateCollection, OnPostUpdate, OnPreRemoveCollection, OnPreUpdateCollection and in your impl do nothing in these methods (only keep base class' OnPostDelete impl). Then pass in this class as an argument to configuration.IntegrateWithEnvers([yourEventListenerHere], enversCfg).

However, Envers might be overkill for you (you cannot use its query API and other stuff if you just store delete info). Maybe a simple implementation of IPostDeleteEventListener is enough in your case (depending on what you want to store)?