tags:

views:

27

answers:

1

I've been using the IPreUpdateEventListener for auditing entities, in particular using the FindDirty method to find the changed properties:

public bool OnPreUpdate(PreUpdateEvent updateEvent)
{ 
    int[] dirtyFieldIndices = updateEvent.Persister.FindDirty(updateEvent.State, updateEvent.OldState, updateEvent.Entity, updateEvent.Session);
    // Get changed property names and audit...
}

This works fine for simple properties. However, my entity has a collection property of other entities. One of these entities has changed, and the change gets persisted, but FindDirty does not give me the index of that collection property. Is there any way of getting hold of the changed property in order to audit this change?

A: 

I have decided to have a method on my domain objects that receives the OldState collection, and applies its own processing on it, checking each object to see if it has changed.

Tevin