-->
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: Synchronized ThreadLocalSession
PostPosted: Tue Jun 15, 2004 8:35 am 
Newbie

Joined: Tue Jun 15, 2004 8:31 am
Posts: 1
I'm incorporating the
Code:
ThreadLocalSession
code, suggested at http://www.hibernate.org/42.html - the one from Steve Ebersole. Doesn't the currentSession method have to be synchronized?

Thanks, Jeff


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 9:06 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Have a look at the HibernateUtil class in chapter 1 of the documentation, which uses a static initializer. (Also replace the catch Exception with catch Throwable in this initializer).

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 9:12 am 
Newbie

Joined: Fri Apr 23, 2004 4:18 pm
Posts: 15
Location: Oslo, Norway
Hi Jeff,

Nope, the currentSession() method does not need to be synchronized.

The point here being that multiple threads executing in this method at the same time will allocate a private Hibernate session (if not already allocated), and store it in "a private place" in the ThreadLocal session attribute.




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.