I use the Seam framework.
If I do
Session sess = (Session)em.getDelegate();
Connection conn = sess.connection();
Is this then a ne开发者_Go百科w connection? And do I have to close the connection manually?
I tested this in a loop in Weblogic app server:
Session sess = (Session)em.getDelegate();
for (int i=1; i<=1000; i++) {
Connection conn = sess.connection();
// ...
//conn.close();
}
And I never saw in the console that the Weblogic pool limit was out of resources and also no forcing of inactive connections to the pool.
From the javadoc:
Get the JDBC connection of this Session. If the session is using aggressive collection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call. Otherwise, the application should not close the connection.
http://docs.jboss.org/hibernate/core/3.5/api/index.html?org/hibernate/Session.html
精彩评论