@Test public void testRollbackWithException() throws Exception { try { Transaction.execute(new TransactionCallbackWithException<Object, FileNotFoundException>() { @Override public Object doInTransaction(final TransactionStatus status) throws FileNotFoundException { assertEquals(TransactionLegacy.CLOUD_DB, TransactionLegacy.currentTxn().getDatabaseId().shortValue()); throw new FileNotFoundException("Panic!"); } }); fail(); } catch (final FileNotFoundException e) { assertEquals("Panic!", e.getMessage()); } verify(conn).setAutoCommit(false); verify(conn, times(0)).commit(); verify(conn, times(1)).rollback(); verify(conn, times(1)).close(); }
public static <T> T execute(final TransactionCallback<T> callback) { return execute(new TransactionCallbackWithException<T, RuntimeException>() { @Override public T doInTransaction(final TransactionStatus status) throws RuntimeException { return callback.doInTransaction(status); } }); }
Transaction { public static <T> T execute(final TransactionCallback<T> callback) { return execute(new TransactionCallbackWithException<T, RuntimeException>() { @Override public T doInTransaction(final TransactionStatus status) throws RuntimeException { return callback.doInTransaction(status); } }); } }
Transaction { public static <T> T execute(final TransactionCallback<T> callback) { return execute(new TransactionCallbackWithException<T, RuntimeException>() { @Override public T doInTransaction(final TransactionStatus status) throws RuntimeException { return callback.doInTransaction(status); } }); }  }
Transaction { public static <T> T execute(final TransactionCallback<T> callback) { return execute(new TransactionCallbackWithException<T, RuntimeException>() { @Override public T doInTransaction(final TransactionStatus status) throws RuntimeException { return callback.doInTransaction(status); } }); }  static T execute(final TransactionCallback<T> callback); static T execute(final TransactionCallbackWithException<T, E> callback); static T execute(final short databaseId, final TransactionCallback<T> callback); static T execute(final short databaseId, final TransactionCallbackWithException<T, E> callback); }
Transaction { public static <T> T execute(final TransactionCallback<T> callback) { return execute(new TransactionCallbackWithException<T, RuntimeException>() { @Override public T doInTransaction(final TransactionStatus status) throws RuntimeException { return callback.doInTransaction(status); } }); }  static T execute(final TransactionCallback<T> callback); static T execute(final TransactionCallbackWithException<T, E> callback); static T execute(final short databaseId, final TransactionCallback<T> callback); static T execute(final short databaseId, final TransactionCallbackWithException<T, E> callback);  }