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: Using interceptors for Auditing
PostPosted: Fri Nov 21, 2008 10:33 am 
Newbie

Joined: Fri Nov 21, 2008 9:59 am
Posts: 3
Location: UK
Hi,

I am planning to use hibernate EmptyInterceptor for performing database auditing.

The idea is: once a record is updated, audit information will be inserted in a separate table. For updates, it should also track old values. (Hence I choosed EmptyInterceptor and also tried PostUpdateEventListener).

Is EmptyInterceptor can be used for such audit requirement. I have refered hibernate reference chapter 12 for this implementation.

Also, I have sessionFactory defined in the config xml file. Using entityInterceptor property, I am setting my implementation of EmptyInterceptor in sessionFactory. Now, this interceptor also requires sessionFactory so that it inserts records in audit table. Here sessionFactory and interceptor requires each other.. and thats the problem.....

Please let me know, in which way I can resolve this. Same issue applies when I use PostUpdateEventListener.


The error I am receiving is:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditDAO' defined in ServletContext resource [spring-config.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sessionFactory': FactoryBean which is currently in creation returned null from getObject


Regards,
Nikam S


Top
 Profile  
 
 Post subject: Use different hibernate session for auditing
PostPosted: Wed Nov 26, 2008 9:08 am 
Newbie

Joined: Fri Nov 21, 2008 9:59 am
Posts: 3
Location: UK
I got the solution for this. For such requirements, we have to use different session. So I am using different hibernate session for audit related db transactions in the event listener class.


Regards,
Nikam S


Top
 Profile  
 
 Post subject: Caution: Do not retrieve user in hibernate interceptor
PostPosted: Wed Nov 26, 2008 11:42 pm 
Newbie

Joined: Sun Mar 23, 2008 9:56 am
Posts: 2
Ba cautious in retrieving Acegi user information within Hibernate context.

We’ve recently discovered a problem in our audit logging facility where Acegi returns a different user other than the actual user. It’s a little hard to replicate because it happens only when multiple users are accessing the system. In summary, audit logs were associated to other users because Acegi SecurityContextHolder is returning incorrect user reference when invoked within a Hibernate interceptor. Our tests showed that retrieving user within the service or DAO layer works correctly but retrieving user from an interceptor may potentially return a different user.

http://www.ideyatech.com/2008/11/a-hidd ... and-acegi/


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.