I am using Ayende's audit event listeners, so that on pre-update and pre-insert, the insert/update dates are tracked (http://ayende.com/ Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp- ipreinserteventlistener.aspx)
The problem I am having is in the case that an entity is inserted, followed by an update occurring to the same entity, within the same transaction. In this case, when the update is executed, the update event's state still contains the old value for InsertDate (i.e. just the default DateTime value), rather than the generated value. So the resulting SQL looks like this: INSERT INTO MyEntity (..., InsertDate, UpdateDate) VALUES (...., '2010-01-04 11:14:00', '2010-01-04 11:14:00') ... (various sql) ... UPDATE MyEntity SET ........, InsertDate = '1957-01-01 00:00:00', UpdateDate = '2010-01-04 11:14:00' This results in an exception. The worrying thing is that I assume this behaviour would also apply to other event listeners that modify the event state, resulting in the possible insertion of incorrect data. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
