-->
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.  [ 4 posts ] 
Author Message
 Post subject: Creating a Temporary Session in Interceptor using HAR
PostPosted: Wed May 04, 2005 11:00 am 
Newbie

Joined: Wed Dec 17, 2003 12:31 pm
Posts: 9
Location: Kent, UK
JBoss: jboss-4.0.1sp1
Hibernate version: 2.1.6
Database Server: SQL Server 2000

I am using the a HAR to deploy my mapping documents, and would like to use the Auditing example in Chapter 8 of Hibernate in Action.

I've seen how to specify an Interceptor in the hibernate-service.xml file, but I am unsure how to create the temporary Hibernate Session needed for making the AuditLog entries. In the example, the Interceptor is passed the Hibernate session through a setSession() method - I'm not sure how can I do the same if the interceptor is instantiated by Hibernate itself?

Do I just call HibernateContext.getSession() inside the Interceptor?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 11:02 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes


Top
 Profile  
 
 Post subject: Still not working
PostPosted: Thu May 05, 2005 9:52 am 
Newbie

Joined: Wed Dec 17, 2003 12:31 pm
Posts: 9
Location: Kent, UK
Further to this, if I use HibernateContext.getSession(), I seem to get the same session, resulting in a loop. HibernateContext.getUnmanagedSession() gets a different session, but that too seems to result in far too many calls to post flush (for every insertion that should have a single audit entry, I get ~1600 entries!).

I think that whether I ask for a managed Session or an unmanaged Session, the Interceptor is registered with the returned Session, which results in a large number of calls to the postFlush() method on the interceptor.

Obviously, I need a session without the interceptor - my interceptor is registered in the hibernate-service.xml within the .har file.

Therefore, should I create a second mbean entry in there with the same contents as the first, except that the interceptor isn't declared, and use that mbean from within the interceptor?

Thanks for your help with this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 11:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please continue this in the JBoss or regular User forum. Thanks


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