Seam - get connection through (session) em.getDelegate ();

I use the Seam structure.

If i do

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

Is this a new mix? And do I need to close the connection manually?

I tested this in a loop on a Weblogic application 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 restriction of the Weblogic pool was out of resources and also did not force inactive connections to the pool.

+3
source share
1 answer

From javadoc:

Get the JDBC connection for this session. If the session uses an aggressive build (as in the CMT environment), the responsibility of closing the connection returned by this call is the responsibility of the application. Otherwise, the application should not close the connection.

http://docs.jboss.org/hibernate/core/3.5/api/index.html?org/hibernate/Session.html

+2

Source: https://habr.com/ru/post/1791486/


All Articles