1 Reply Latest reply on Mar 19, 2007 2:08 PM by Adrian Brock

    Setting isolation level for certain Connection

    Konstantin Krivopustov Newbie

      I use Hibernate with JBoss EJB3 session beans, and I need to decrease isolation level for some method to eliminate a concurrency issue.

      Is it possible to get the Connection from current Hibernate session, set appropriate isolation level, make call to database through this connection, and close it?

      As I understand, when I close Connection, it is returned into connection pool. When next EJB method gets this connection from the pool, will it be set to my last isolation level or to default (set in *-ds.xml)?
      So is it correct to set isolation level for pooled connection?

        • 1. Re: Setting isolation level for certain Connection
          Adrian Brock Master

          Use the source Luke :-)

          ManagedConnection.cleanup() is invoked as part of the JCA spec
          contract when a connection is returned to the pool.

           public void cleanup() throws ResourceException
           //reset all the properties we know about to defaults.
           synchronized (stateLock)
           jdbcAutoCommit = true;
           jdbcReadOnly = readOnly;
           if (jdbcTransactionIsolation != transactionIsolation)
           jdbcTransactionIsolation = transactionIsolation;
           catch (SQLException e)
           mcf.log.warn("Error resetting transaction isolation ", e);