views:

424

answers:

2

Hi,

I can easily log last modified date, modified by etc. However, I need old and new value to be logged too. In the interceptor, I can fire a select before postflush starts executing to get the value of the current record. Then I can run a diff between this record and the new one to see what changed and log that information as old and new values. Is there a better way?

The problem is my object to be modified can be really huge with references to other objects too. Doing a diff can be expensive.

-thanks

A: 

Why not use audit tables and triggers?

HLGEM
+1  A: 

Overriding onFlushDirty of EmptyInterceptor(IInterceptor) gives you arrays previousState and currentState. You can use these two arrays to find the oldvalue and newvalue.

look at this example

Deepak N