I recently have found out how to audit instances with the IPreDeleteEventListener, IPreInsertEventListener and IPreUpdateEventListener
The returned value in this case should be enum, Let's use the name OnPreEventResult, and these would be the possible values:
OnPreEventResult.Continue => to continue currently return falseOnPreEventResult.Break => at the moment, when the true is returned the Action is abortedSo, as both examples above show, we can use the return value to manage the execution flow:
to Continue:
If we in the AuditEventListener return false, we in fact return something like OnPreEventResult.Continue. We've made some custome logic, and we want NHibernate to continue... so the false is returned
to Break/Abort:
Ayende's example is showing us how to change the real DELETE into UPDATE. Update is called explicitly @event.Persister.Update(... and the delete is not executed due to the returned value true, i.e. OnPreEventResult.Break
In the code, the returned values are stored in local variable called veto, which is again more self descriptive.
See:
A snippet from the EntityInsertAction, the Execute() method:
...
bool veto = PreInsert();
if (!veto)
{
persister.Insert(id, state, instance, Session);
...