-->
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: Why is the reconnect() method deprecated?
PostPosted: Sun Feb 19, 2006 12:38 pm 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
In my application I use the long conversations. After process a request, I store the disconnected session in HttpSession and on next request, reconnect the stored session and work with it further. In Hibernate3 is the reconnect() method deprecated, what must I use instead of this? This I saw in the API documentation: "Manual reconnection is only needed in the case of application-supplied connections, in which case the Session.reconnect(java.sql.Connection) for should be used. " I use no application-supplied connections, and I don't want use they, because I need no manually connection control, and I want to keep the abstraction to the underlying JDBC connection. Must I leave the connection active? But in this case I will possibly have too many opened database connections!
Can you give me an advice?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 19, 2006 3:18 pm 
Beginner
Beginner

Joined: Sun Feb 19, 2006 3:50 am
Posts: 34
Take a look at the Field Summary section of http://www.hibernate.org/hib_docs/v3/api/org/hibernate/ConnectionReleaseMode.html

In Hibernate 3.1 or later, by default JDBC connections are automatically released at the end of a transaction (it's using the AFTER_TRANSACTION option from the link above) and reconncected as necessary. So the only reason you would ever need to explicitly reconnect in the session is if you're using application-supplied connections (i.e. you're *not* using a connection pool). And in that case you have to provide the Connection object using reconnect(Connection), so the no-argument reconnect() is unnecessary.

This is good news. It means you don't have to store any connections in your session or do anything special with the connections. The default in Hibernate 3.1 or later is to aggressively release the connection at the end of a transaction and reconnect for you automatically as necessary.


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.