I did briefly try that, and ended up having some different issues (don't remember exactly what the problem was now, I'll try to reproduce that on Monday).
Does FlushEventListener get called for dirty objects only? Cheers, Krzysztof On May 6, 10:04 pm, Fabio Maulo <[email protected]> wrote: > IPreUpdate is intended to be used for entity-state checking (veto) not to > change the state. > What is happening is that NH found a strange operation in a collection > (something like "somebody have changed it outside my control or I have a > bug"). > For what you need you have to use ISaveOrUpdateEventListener > public void OnSaveOrUpdate(SaveOrUpdateEvent @event) > { > var trackable = @event.Entity as ITrackModificationDate; > if (trackable != null) > { > trackable.LastModified = CurrentDateTimeProvider(); > > } > } > > and IFlushEntityEventListener > public void OnFlushEntity(FlushEntityEvent @event) > { > if(@event.EntityEntry.Status == Status.Deleted) > { > return;} > > var trackable = @event.Entity as ITrackModificationDate; > if (trackable != null) > { > trackable.LastModified = CurrentDateTimeProvider(); > > } > } > > As you can see, using right events you don't need to use NH internals state. > > For collection you have another set of events. In general *you shouldn't > initialize a collection* in an NH's event. > > 2011/5/6 Krzysztof Koźmic <[email protected]> > > > > > > > > > > > I'm using Oracle database. > > I have a IPreUpdateEventListener and IPreInsertEventListener which set > > CreatedBy and UpdatedBy properties on some of the entities. > > > Those properties point to another entity Person which is assigned in the > > listeners via Session.Load<> > > > this all used to work quite nice when I had my POID generator specified as > > "sequence-identity" (we use sequences in Oracle) > > > today I tried to switch POID generator to "sequence" which would allow me > > to utilize batching which I also enabled. > > > Here's where I started getting this exception: > > > collection: [Person.FooBars] was not processed by flush() > > > the exception happens only when the Session.Load<> in my event listeners > > doesn't already have the Person I'm requested accessible (that is only when > > Load<Person> returns a proxy). If I load the person beforehand (and not in > > the listener) the exception does not occur. > > > Any ideas what the reason for that is and how do I fix it? > > > Krzysztof > > > -- > > 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. > > -- > Fabio Maulo -- 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.
