@Override public Integer execute(Connection connection) throws SQLException { return connection.getTransactionIsolation(); } }
@Override public int getTransactionIsolation() throws SQLException { return targetConnection.getTransactionIsolation(); }
@Override public int getTransactionIsolation() throws SQLException { return raw.getTransactionIsolation(); }
@Override public int getTransactionIsolation() throws SQLException { return raw.getTransactionIsolation(); }
/** * Check the default connection properties (auto-commit, transaction isolation), * keeping them to be able to expose them correctly without fetching an actual * JDBC Connection from the target DataSource. * <p>This will be invoked once on startup, but also for each retrieval of a * target Connection. If the check failed on startup (because the database was * down), we'll lazily retrieve those settings. * @param con the Connection to use for checking * @throws SQLException if thrown by Connection methods */ protected synchronized void checkDefaultConnectionProperties(Connection con) throws SQLException { if (this.defaultAutoCommit == null) { this.defaultAutoCommit = con.getAutoCommit(); } if (this.defaultTransactionIsolation == null) { this.defaultTransactionIsolation = con.getTransactionIsolation(); } }
@Override public int getTransactionIsolation() throws SQLException { return connection.getTransactionIsolation(); }
ConnInfo(DataSource ds, Connection conn, int level, boolean restoreAutoCommit) throws SQLException { this.ds = ds; this.conn = conn; this.oldLevel = conn.getTransactionIsolation(); if (this.oldLevel != level) { conn.setTransactionIsolation(level); this.restoreIsoLevel = true; } this.restoreAutoCommit = restoreAutoCommit; }
@Override public final int getTransactionIsolation() throws SQLException { if (cachedConnections.values().isEmpty()) { return transactionIsolation; } return cachedConnections.values().iterator().next().getTransactionIsolation(); }
@Override @SuppressWarnings("UnnecessaryUnboxing") public Connection getConnection() throws SQLException { final Connection c = ds.getConnection(); if ( isolation != null && !isolation.equals( c.getTransactionIsolation() ) ) { c.setTransactionIsolation( isolation.intValue() ); } if ( c.getAutoCommit() != autocommit ) { c.setAutoCommit( autocommit ); } return c; }
/** {@inheritDoc} */ @Override public int getTransactionIsolation() throws SQLException { return conn.getTransactionIsolation(); }
@Override public int getTransactionIsolation() throws SQLException { blockUntilAvailable(); return connection.getTransactionIsolation(); }
@Override public int getTransactionIsolation() throws SQLException { return _baseConn.getTransactionIsolation(); }
@Override public void run() throws Exception { conn.getTransactionIsolation(); } });
definition.getIsolationLevel()); int currentIsolation = con.getTransactionIsolation(); if (currentIsolation != definition.getIsolationLevel()) { previousIsolationLevel = currentIsolation;
@Override public int connection_getTransactionIsolation(ConnectionProxy connection) throws SQLException { if (this.pos < filterSize) { return nextFilter() .connection_getTransactionIsolation(this, connection); } return connection.getRawObject() .getTransactionIsolation(); }
@Override public int getTransactionIsolation() throws SQLException { TestObjectStoreInitRetry.debugTrace(); return _baseConn.getTransactionIsolation(); }
/** * @throws Exception If failed. */ @Test public void testTxAllowedRollback() throws Exception { String url = CFG_URL_PREFIX + "transactionsAllowed=true@" + configURL(); try (final Connection conn = DriverManager.getConnection(url)) { conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); assertEquals(Connection.TRANSACTION_SERIALIZABLE, conn.getTransactionIsolation()); conn.setAutoCommit(false); conn.rollback(); } }
/** * @throws Exception If failed. */ @Test public void testTxAllowedCommit() throws Exception { String url = CFG_URL_PREFIX + "transactionsAllowed=true@" + configURL(); try (final Connection conn = DriverManager.getConnection(url)) { conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); assertEquals(Connection.TRANSACTION_SERIALIZABLE, conn.getTransactionIsolation()); conn.setAutoCommit(false); conn.commit(); } }
@Test public void testTransactionWithIsolationAndReadOnly() throws Exception { given(con.getTransactionIsolation()).willReturn(Connection.TRANSACTION_READ_COMMITTED); given(con.getAutoCommit()).willReturn(true); TransactionTemplate tt = new TransactionTemplate(tm); tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); tt.setIsolationLevel(TransactionDefinition.ISOLATION_SERIALIZABLE); tt.setReadOnly(true); assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds)); tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { assertTrue(TransactionSynchronizationManager.isCurrentTransactionReadOnly()); assertTrue(TransactionSynchronizationManager.isActualTransactionActive()); // something transactional } }); assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(ds)); InOrder ordered = inOrder(con); ordered.verify(con).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); ordered.verify(con).setAutoCommit(false); ordered.verify(con).commit(); ordered.verify(con).setAutoCommit(true); ordered.verify(con).setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); verify(con).close(); }
given(con.getTransactionIsolation()).willReturn(Connection.TRANSACTION_READ_COMMITTED);