Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: A couple of questions
PostPosted: Fri Aug 29, 2003 12:28 am 
Newbie

Joined: Tue Aug 26, 2003 6:57 pm
Posts: 3
1. The JavaDocs on SessionFactory.openSession() state that it "Create[s] database connection and open a Session on it. " Does it actually _create_ a connection, or does it use/reuse one from the pool?

2. In a servlet environment, would it be advisable to store a Session in the HttpSession, reconnecting and disconnecting the Connection when needed, instead of close()ing the Session? If not, why not?

3. Any plan to support ConnectionPoolDataSource, like Driver, without using JNDI? This would make connection pooling possible without relying on third party pool implementations.

Thanks,
Nils


Top
 Profile  
 
 Post subject: Re: A couple of questions
PostPosted: Fri Aug 29, 2003 8:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Quote:
1. The JavaDocs on SessionFactory.openSession() state that it "Create[s] database connection and open a Session on it. " Does it actually _create_ a connection, or does it use/reuse one from the pool?


openSession() gets a connection from a configured pool, openSession(connection) re-uses the given connection.

Quote:
2. In a servlet environment, would it be advisable to store a Session in the HttpSession, reconnecting and disconnecting the Connection when needed, instead of close()ing the Session? If not, why not?


This is possible, but not advisable. The acts also as a cache of objects and you may see stale data. It is ok to disconnect/reconnect the Session for a couple of HttpRequest/Response cycles as long as you are aware of the caching issues.

_________________
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  
Post new topic Reply to topic  [ 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.