예제 #1
0
  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());
  }
예제 #2
0
  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();
  }