-->
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: Hibernate Sessions and Singletons...
PostPosted: Tue Oct 14, 2003 4:08 pm 
Newbie

Joined: Tue Oct 14, 2003 3:51 pm
Posts: 2
I have just started to use Hibernate... wonderfully easy to persist and retrieve data... but I need to run it under a webservice server (glue) and I have always done my DAO thru a singleton connection manager... I looked at the ThreadLocal information, and understand what it is doing, but don't know if that is the right implementation for my scenerio...

In my tests with Hibernate, I notice that starting up the process takes quite a bit of time... once running, using it is very fast... should I put the code for the Configuration and SessionFactory in a Singleton and call that from the ThreadLocal class, or just forgo the whole ThreadLocal part and put the SessionFactory in a Singleton and get the sessions from there... although that seems like it would be a bottleneck for scalibility...

Thanks for any input...

JH


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 4:11 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It is not a bottleneck. You can also automatically bind a SessionFactory to JNDI (on startup) and retrieve it later everytime you need a Session. A singleton/threadlocal combo looks like this:

http://www.hibernate.org/114.html

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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 14, 2003 4:11 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh, this example needs some "synchronize" :)

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


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.