Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seam - get Connection via (Session)em.getDelegate();

I use the Seam framework.

If I do

Session sess = (Session)em.getDelegate();
Connection conn = sess.connection();

Is this then a new 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.

like image 751
August Avatar asked Mar 25 '26 03:03

August


1 Answers

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

like image 94
jpkrohling Avatar answered Mar 28 '26 03:03

jpkrohling



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!