-->
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.  [ 2 posts ] 
Author Message
 Post subject: SessionFactory scope
PostPosted: Wed Apr 18, 2007 7:26 pm 
Newbie

Joined: Fri Apr 13, 2007 12:25 pm
Posts: 17
Hi-

I am having an issue in my application where every time I create an instance of the SessionFactory class, it creates 5 pooled database connections. I am using a homemade HibernateUtil class (like i have seen in many examples) to create and return this SessionFactory, and then using to get session objects from it. I am using tomcat servlets and they call a POJO business object class, which instantiates this session factory on each request. It is quickly becoming apparent that this is not the way to do things, so should I be saving the session factory to JNDI or something? can I do this with tomcat? How can I reuse the SessionFactory object so I don't kill my database with connections after a handful of servlet requests?


Top
 Profile  
 
 Post subject: duh...
PostPosted: Wed Apr 18, 2007 7:42 pm 
Newbie

Joined: Fri Apr 13, 2007 12:25 pm
Posts: 17
I was using a static variable to store the SessionFactory, but I was actually recreating the SessionFactory each time. I set it to final, created it once, and this solved my problem... That was really dumb, sorry everyone. Can I get a credit for answering my own problem?


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