-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Audit trail with new and old values using an Inteceptor
PostPosted: Thu Feb 11, 2010 5:58 am 
Newbie

Joined: Thu Feb 11, 2010 5:53 am
Posts: 5
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. So, say 25 parameters in my object changed. My audit trail will contain 25 rows minimum. 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. Plus the total number of queries executing is really a lot.

-thanks


Top
 Profile  
 
 Post subject: Re: Audit trail with new and old values using an Inteceptor
PostPosted: Thu Feb 25, 2010 12:53 pm 
Beginner
Beginner

Joined: Tue Aug 25, 2009 11:42 am
Posts: 49
Have u tried to use envers?


Top
 Profile  
 
 Post subject: Re: Audit trail with new and old values using an Inteceptor
PostPosted: Fri Feb 26, 2010 3:35 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The Interceptor.onFlushDirty() method contains arrays with both the old and new values as well as all property names and types. I am using it to create log message like: User foo changed properties a, b and c of object X at 2010-02-26 08:31. I don't log the new/old values, but it would have been possible to do that as well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.