What should I return from the NHibernate event listener?

public class MyUpdateListener : IPreUpdateListener
{
    public bool OnPreUpdate(PreUpdateEvent @event)
    {
           // What do I return from this method - true or false?
    }
}
+5
source share
1 answer

I also thought about this and could not find a definitive answer. Therefore, I lowered the 2.1.1.GA source code and found the answer: returning true from OnPreInsert, OnPreUpdate or OnPreDelete will veto (i.e. cancel) the corresponding insert, update or delete operation. The rest of the Pre listeners return to the void.

The most common use of IPreInsertListener and IPreUpdateListener is to add write-level audit , and for these tasks you should return false.

+13
source

All Articles