-->
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: Recommendation for Audit pattern - Interceptor or Listener?
PostPosted: Wed Apr 27, 2005 5:41 am 
Newbie

Joined: Wed Apr 27, 2005 5:31 am
Posts: 5
Location: UK
Hi,

Using Hibernate 3 and trying to build some automatic change-auditing code to add into the persistence layer. What I'd like to do is have a table that logs the old and new value of each field when it's updated and saved to the database.

I've started off by using the example in Chapter 8 of Hibernate in Action which uses an Interceptor class to build a "change list" and then after the session has been flushed, saves the details of the changes to the audit tables.

Would you recommend using the Interceptor for this, or would the Event Listener mechanism be more appropriate for this task?

Any pointers to example code for doing this sort of this would be really appreciated.

Thanks,
David.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 27, 2005 2:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Currently, I'd recommend the Interceptor approach.

The reasoning is that the Listeners are really mis-named; they are actually event-handlers or event-processors. So if you go the Listener approach, your class is basically responsible for processing the generated event in-total. Of course you can just extend the appropriate default Listener, but then you'd have to know which protected methods to tie into in order to get at the needed state, etc. Hopefully this will all be simplified at some stage.


Top
 Profile  
 
 Post subject: would your recommend either of these 2 solutions?
PostPosted: Thu Jul 20, 2006 2:00 pm 
Newbie

Joined: Thu Jul 20, 2006 1:56 pm
Posts: 4
For Hibernate 3.1?

http://www.hibernate.org/318.html
http://forum.hibernate.org/viewtopic.ph ... r&start=30

We're trying to find the best audit interceptor solution to use for a new application. thx


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.