@Test
public void rollbacksWithoutThirdPartyTransactions() throws SQLException {
Connection connection = dataSource.getConnection();
try {
TransactionManager tm = new SingleConnectionTransactionManager(connection, false);
final Database db = new Database(tm);
db.update("drop table if exists test_table");
db.update("create table test_table (text varchar(64))");
db.update("insert into test_table (text) values ('foo')");
db.withTransaction(new TransactionCallback<Object>() {
@Nullable
@Override
public Object execute(@NotNull TransactionContext tx) {
db.update("update test_table set text='bar'");
tx.setRollbackOnly();
return null;
}
});
assertThat(db.findUnique(String.class, "select text from test_table"), is("foo"));
} finally {
connection.close();
}
}