-->
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.  [ 6 posts ] 
Author Message
 Post subject: AuditLogInterceptor example
PostPosted: Thu Jun 30, 2005 2:22 pm 
Newbie

Joined: Tue May 31, 2005 8:19 pm
Posts: 16
Location: San Francisco, CA
Why is an AuditLog class used, instead of putting the persistence code directly in the postFlush method of the AuditLogInterceptor ?

I'm wondering if this was done some technical reasons, which I don't see, or for design reasons. If for design reasons, it looks like this is done for the situation where there may be multiple instances of the Interceptor, as opposed to a global (singleton) Interceptor (such as one wired into Spring's Hibernate LocalSessionFactoryBean).

Can you tell me why it was done this way ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 30, 2005 2:45 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because it looks better.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 1:08 pm 
Newbie

Joined: Tue May 31, 2005 8:19 pm
Posts: 16
Location: San Francisco, CA
I've implemented an AuditLogInterceptor similar to the one in HIA.

Like the example, I have an explicit flush call, so that the audit data will be created in postFlush, and then will be persisted at the end of the transaction.

There is one minor annoyance I am encountering with this model. When the transaction ends, not only is the audit data begin persisted as desired, but the domain object is being updated again even though it has not been updated since the explicit call to flush. I believe that this is happening because the domain object has a <timestamp> for managed versioning, and so Hibernate is detecting that the entity is dirty simply because the timestamp was updated during the last update.

Is there any way I can get rid of this unnecessary update ?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 1:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No idea, use the regular user forum.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 1:29 pm 
Newbie

Joined: Tue May 31, 2005 8:19 pm
Posts: 16
Location: San Francisco, CA
fair enough --- I will

let me just ask one question strictly related to the book --- given that it states that flush() is rarely used except for such things as triggers and mixing with JDBC, there is no reason given in the AuditLogInterceptor example for the use of an explicit flush() --- am I correct in assuming that this is done to create the audit data in postFlush, so that the audit data itself will be persisted when the transaction ends ? or is there some other reason why an explicit flush is used in the example ?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 1:52 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The method has all kinds of uses, esp. if you write application transactions with a FlushMode.NEVER and long Session. In the example it was used to show that flush has to happen for postFlush() and onFlushDirty() to run, of course...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.