Please may I ask for clarification on the semantics/ usage of
PreUpdate vs OnSaveOrUpdate listeners based on NH-2596 (http://
216.121.112.228/browse/NH-2596).
After reading Ayende's blog posts on NHibernate
IPreUpdateEventListener & IPreInsertEventListener (
http://ayende.com/
Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-
ipreinserteventlistener.aspx) with an audit trail example I adopted
this method myself. During my learning I raised NH-2617 (http://
216.121.112.228/browse/NH-2617) issue, where I found PreUpdate event
data changes on an entity which is only modified in the PreUpdate
event is not persisted.
My issue was closed as a duplicate of NH-2596. However, NH-2596 is
also closed as “not an issue” with the solution to use the
OnSaveOrUpdate event listeners on the basis that pre-insert and pre-
update listeners are not intended to be used to change the values of
the entity. Instead they should be used to check-values (for that
reason they return "veto").
I am alittle confused as to the best practice usages/ semantics of
PreUpdate vs OnSaveOrUpdate now. Would someone be able to clarify why
the use of PreInsert and PreUpdate is used by many for Audit trailing
but incorrectly? Or why is the OnSaveOrUpdate listener suggested in
the closure of NH-2596 and this non peristance is not an issue.
Many thanks, Scott.