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: Improved Thread Local Pattern - Q
PostPosted: Wed Apr 25, 2007 8:45 am 
Newbie

Joined: Wed Apr 25, 2007 6:50 am
Posts: 9
in the Improved Thread Local Pattern description
http://www.hibernate.org/207.html
it is said at the bottom:
Quote:
From the caller perspective he always gets an Ownership object and calls that closeSession with that identity as a parameter. For instance if the transaction flow is like Container1Servlet1----> Container1EJB1(M1-TXRequiresNew) ----> Container1EJB1(M2-TXRequired) , then both Container1EJB1(M1) and Container1EJB1(M2) will call the open session and close session at the beginning and end of the methods respectively. But the actual open will happen at the beginning of Container1EJB1(M1) (since there is no session associated at this time) and closes at the end of Container1EJB1(M1), (since M1 is the actual owner of the session)This ensures a single session per request.


So, what if M2 has the session still open (and needs it) when M1 closes it...
I am probably missing something...

Anyone showing me the path? Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 8:49 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
I think that that particular pattern is deprecated in favor of contextual sessions. In a clustered environment, like the one described, the use of the JTA contextual sessions would be the most effective. I've not deployed to a clustered environment, so your mileage may vary.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 9:17 am 
Newbie

Joined: Wed Apr 25, 2007 6:50 am
Posts: 9
even if that is deprecated, it was probably correct at that time...

in the example I quoted the is only one container and two methods from the same bean Container1EJB1.

The question was:

Quote:
..what if M2 has the session still open (and needs it) when M1 closes it...


is there an answer for that?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 12:22 pm 
Newbie

Joined: Fri Apr 20, 2007 3:46 pm
Posts: 15
Well you have one bean and two methods M1 ( RequiresNew) and M2 ( Required). If you opened and closed session in M1 and then did the same thing in M2 it would still work but you would not have one session per request, instead you would be opening two sessions.

You could open/close only in M1 only if it is not possible to directly call M2. If it is then I guess he/she wanted to control when the close session would really close. So if you called close on M2 it would not actually close anything since M1 is the method that called open. if M2 is called directly then actually it would be able to do open/close


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.