@Override public void rollback(Savepoint savePoint) throws SQLException { if (proxy != null) { proxy.rollback(savePoint); } }
@Override public void rollback(Savepoint savePoint) throws SQLException { if (proxy != null) { proxy.rollback(savePoint); } }
@Override public void rollBack(DatabaseConnection connection) throws SQLException { connection.rollback(null); }
@Override public void rollBack(DatabaseConnection connection) throws SQLException { connection.rollback(null); }
@Override public void rollback() throws IllegalStateException, SystemException { if(status == Status.STATUS_ROLLEDBACK || status == Status.STATUS_COMMITTED) { return; } status = Status.STATUS_ROLLING_BACK; try { try { connection.rollback(savepoint); } catch (SQLException e) { throw new RuntimeException(e); } } finally { status = Status.STATUS_ROLLEDBACK; } }
private static void rollBack(DatabaseConnection connection, Savepoint savePoint) throws SQLException { String name = (savePoint == null ? null : savePoint.getSavepointName()); connection.rollback(savePoint); if (name == null) { logger.trace("rolled back savePoint transaction"); } else { logger.trace("rolled back savePoint transaction {}", name); } }
private static void rollBack(DatabaseConnection connection, Savepoint savePoint) throws SQLException { String name = (savePoint == null ? null : savePoint.getSavepointName()); connection.rollback(savePoint); if (name == null) { logger.trace("rolled back savePoint transaction"); } else { logger.trace("rolled back savePoint transaction {}", name); } }
@Test public void testRollback() throws Exception { DatabaseConnection conn = createMock(DatabaseConnection.class); conn.rollback(null); conn.close(); DatabaseConnectionProxy proxy = new DatabaseConnectionProxy(conn); replay(conn); proxy.rollback(null); proxy.close(); verify(conn); }
@Test public void testTransactionManagerRollbackOtherException() throws Exception { ConnectionSource connectionSource = createMock(ConnectionSource.class); DatabaseConnection conn = createMock(DatabaseConnection.class); expect(conn.isAutoCommitSupported()).andReturn(false); Savepoint savePoint = createMock(Savepoint.class); expect(savePoint.getSavepointName()).andReturn("name").anyTimes(); expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint); conn.rollback(savePoint); expect(connectionSource.getDatabaseType()).andReturn(databaseType); expect(connectionSource.getReadWriteConnection(null)).andReturn(conn); expect(connectionSource.saveSpecialConnection(conn)).andReturn(true); connectionSource.clearSpecialConnection(conn); connectionSource.releaseConnection(conn); replay(connectionSource, conn, savePoint); TransactionManager tm = new TransactionManager(connectionSource); try { tm.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { throw new Exception("you better roll back!!"); } }); fail("expected an exception"); } catch (Exception e) { // expected } verify(connectionSource, conn, savePoint); }
@Test public void testTransactionManagerRollbackNullSavePoint() throws Exception { ConnectionSource connectionSource = createMock(ConnectionSource.class); DatabaseConnection conn = createMock(DatabaseConnection.class); expect(conn.isAutoCommitSupported()).andReturn(false); expect(conn.setSavePoint(isA(String.class))).andReturn(null); conn.rollback(null); expect(connectionSource.getDatabaseType()).andReturn(databaseType); expect(connectionSource.getReadWriteConnection(null)).andReturn(conn); expect(connectionSource.saveSpecialConnection(conn)).andReturn(true); connectionSource.clearSpecialConnection(conn); connectionSource.releaseConnection(conn); replay(connectionSource, conn); TransactionManager tm = new TransactionManager(connectionSource); try { tm.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { throw new SQLException("you better roll back!!"); } }); fail("expected an exception"); } catch (SQLException e) { // expected } verify(connectionSource, conn); }
@Test public void testTransactionManagerRollback() throws Exception { ConnectionSource connectionSource = createMock(ConnectionSource.class); DatabaseConnection conn = createMock(DatabaseConnection.class); expect(conn.isAutoCommitSupported()).andReturn(false); Savepoint savePoint = createMock(Savepoint.class); expect(savePoint.getSavepointName()).andReturn("name").anyTimes(); expect(conn.setSavePoint(isA(String.class))).andReturn(savePoint); conn.rollback(savePoint); expect(connectionSource.getDatabaseType()).andReturn(databaseType); expect(connectionSource.getReadWriteConnection(null)).andReturn(conn); expect(connectionSource.saveSpecialConnection(conn)).andReturn(true); connectionSource.clearSpecialConnection(conn); connectionSource.releaseConnection(conn); replay(connectionSource, conn, savePoint); TransactionManager tm = new TransactionManager(connectionSource); try { tm.callInTransaction(new Callable<Void>() { @Override public Void call() throws Exception { throw new SQLException("you better roll back!!"); } }); fail("expected an exception"); } catch (SQLException e) { // expected } verify(connectionSource, conn, savePoint); }