public void testBeginAndCommitTransaction() throws Exception { TransactionStuff txl = SqlObjectBuilder.attach(handle, TransactionStuff.class); txl.insert(8, "Mike"); txl.begin(); txl.updateName(8, "Miker"); assertEquals("Miker", txl.byId(8).getName()); txl.rollback(); assertEquals("Mike", txl.byId(8).getName()); }
public void testTransactionIsolationActuallyHappens() throws Exception { TransactionStuff txl = SqlObjectBuilder.attach(handle, TransactionStuff.class); TransactionStuff tx2 = SqlObjectBuilder.open(dbi, TransactionStuff.class); txl.insert(8, "Mike"); txl.begin(); txl.updateName(8, "Miker"); assertEquals("Miker", txl.byId(8).getName()); assertEquals("Mike", tx2.byId(8).getName()); txl.commit(); assertEquals("Miker", tx2.byId(8).getName()); tx2.close(); }