-->
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: How can I close SessionFactory when undeploying application?
PostPosted: Fri Sep 07, 2007 12:11 pm 
Beginner
Beginner

Joined: Wed May 23, 2007 1:07 pm
Posts: 28
I am using hibernate in a JSP application deployed in Tomcat.

In Postgres I see that I tend to acumulate a lot of idle connections when developing my application. I figured out that I am creating 2 connections in my C3p0 managed connection pool on each deplyoment, which remain idle (and inaccessible) after I redeploy the application.

Because I'm using a static variable for my sessionfactory, I believe the reason for these idle connections that acumulate is the fact that I'm not closing the SessionFactory before I undeploy the application.

How can I close everything up before I redeploy the application. I use Ant to deploy/undeploy/redeploy the application in Eclipse.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 3:34 pm 
Beginner
Beginner

Joined: Thu Jun 17, 2004 11:25 pm
Posts: 21
Location: Los Angeles
You clean up the SessionFactory by calling SessionFactory.close(). If your question is how you do know when to call it, that is, how does Tomcat let your application know it is being undeployed, that's a question for the Tomcat folks.

=Jeremy=


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 07, 2007 7:26 pm 
Beginner
Beginner

Joined: Wed May 23, 2007 1:07 pm
Posts: 28
jgro wrote:
You clean up the SessionFactory by calling SessionFactory.close(). If your question is how you do know when to call it, that is, how does Tomcat let your application know it is being undeployed, that's a question for the Tomcat folks.

=Jeremy=


Yes, my question was regarding when to call the close() method.

For those interested, one solution is to implement a ServletContextListener and put the sessionfactory.close() on its contextdestroyed method.


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.