-->
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: getCurrentSession with Interceptors
PostPosted: Mon May 09, 2005 12:12 pm 
Beginner
Beginner

Joined: Tue Dec 09, 2003 3:27 pm
Posts: 21
I want to take advantage of the new getCurrentSession in Hib 3, however I see no way to assign an interceptor to the session. I currently use the openSession(Interceptor) method since I don't want all sessions to use the interceptor.

Was this an oversight or a design decission?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 2:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
As discussed before, this was an over-sight. But not in the way you are suggesting.

SessionFactory.getCurrentSession(Interceptor) make "absolutely no sense*. Basically you apply a SessionFactory-scoped Interceptor.

Now, what was (and has been) an oversight, is that there is no good way to obtain a non-intercepted session from a SessionFactory which has a defined Interceptor. There is, but you'd need to build a "no op" Interceptor and pass it in to openSession(). This part will be addressed in the next release.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 3:58 pm 
Beginner
Beginner

Joined: Tue Dec 09, 2003 3:27 pm
Posts: 21
I'm just curious, where was this discussed I did a quick search before I posted and came up empty?

The only problem with your solution I see is that currently we have a couple of interceptors that are used in certain scenarios. We can't just use one on the Configuration object. Also our interceptors take constructor parameters so even if we only had one interceptor class, setting it once on the Configuration object won't work.

I can see where SessionFactory.getCurrentSession(Interceptor) doesn't make any sense since you probably don't have access to the interceptor instance after the initial call.

After looking at the code in SessionFactoryImpl, what I'd like to see is that openSession be hooked up to the currentSessionMap so that one could optionally make the call to either openSession() or openSession(Interceptor), then subsequent calls to getCurrentSession would return that session.

With that said maybe this is out of scope of what getCurrentSession is supposed to do so we can look at other ways to handle this.


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.