From: Adrian B. <ej...@us...> - 2004-04-23 16:51:54
|
User: ejort Date: 04/04/23 09:51:48 Modified: src/main/org/jboss/resource/adapter/jdbc BaseWrapperManagedConnection.java Log: Allow the transaction isolation to be overridden inside a managed transaction. Let the driver/db decide whether this is legal. Revision Changes Path 1.5 +16 -24 jbosscx/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java Index: BaseWrapperManagedConnection.java =================================================================== RCS file: /cvsroot/jboss/jbosscx/src/main/org/jboss/resource/adapter/jdbc/BaseWrapperManagedConnection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- BaseWrapperManagedConnection.java 26 Feb 2004 22:38:00 -0000 1.4 +++ BaseWrapperManagedConnection.java 23 Apr 2004 16:51:48 -0000 1.5 @@ -67,7 +67,6 @@ protected boolean jdbcReadOnly; protected boolean underlyingReadOnly; protected int jdbcTransactionIsolation; - protected int underlyingTransactionIsolation; protected boolean destroyed = false; public BaseWrapperManagedConnection (final BaseWrapperManagedConnectionFactory mcf, @@ -108,7 +107,6 @@ underlyingReadOnly = readOnly; jdbcReadOnly = readOnly; - underlyingTransactionIsolation = this.transactionIsolation; jdbcTransactionIsolation = this.transactionIsolation; } // implementation of javax.resource.spi.ManagedConnection interface @@ -204,8 +202,19 @@ synchronized (stateLock) { jdbcAutoCommit = true; - jdbcTransactionIsolation = transactionIsolation; jdbcReadOnly = readOnly; + if (jdbcTransactionIsolation != transactionIsolation) + { + try + { + con.setTransactionIsolation(jdbcTransactionIsolation); + jdbcTransactionIsolation = transactionIsolation; + } + catch (SQLException e) + { + mcf.log.warn("Error resetting transaction isolation ", e); + } + } } } @@ -404,13 +413,6 @@ { synchronized (stateLock) { - // Check the isolation level - if (jdbcTransactionIsolation != underlyingTransactionIsolation) - { - con.setTransactionIsolation(jdbcTransactionIsolation); - underlyingTransactionIsolation = jdbcTransactionIsolation; - } - // Check readonly if (jdbcReadOnly != underlyingReadOnly) { @@ -426,10 +428,7 @@ */ boolean isJdbcAutoCommit() { - synchronized (stateLock) - { - return inManagedTransaction? false: jdbcAutoCommit; - } + return inManagedTransaction? false: jdbcAutoCommit; } /** @@ -453,10 +452,7 @@ */ boolean isJdbcReadOnly() { - synchronized (stateLock) - { - return jdbcReadOnly; - } + return jdbcReadOnly; } /** @@ -480,10 +476,7 @@ */ int getJdbcTransactionIsolation() { - synchronized (stateLock) - { - return jdbcTransactionIsolation; - } + return jdbcTransactionIsolation; } /** @@ -495,8 +488,7 @@ { synchronized (stateLock) { - if (inManagedTransaction) - throw new SQLException("You cannot set isolation level during a managed transaction!"); + con.setTransactionIsolation(jdbcTransactionIsolation); this.jdbcTransactionIsolation = isolationLevel; } } |