return new JtxTransactionMode().propagationRequired().readOnly(false);
}
@Test
public void testRequired() {
LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
// session #1: required - commit
JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
assertTrue(jtx.isActive());
assertNotNull(jtx);
DbSession session = sessionProvider.getDbSession();
executeUpdate(session, "insert into GIRL values(1, 'Sophia', null)");
assertTrue(jtx.isActive());
assertFalse(jtx.isCommitted());
assertFalse(jtx.isNoTransaction());
assertTrue(worker.maybeCommitTransaction(jtx));
assertFalse(jtx.isActive());
assertTrue(jtx.isCommitted());
assertFalse(jtx.isNoTransaction());
// session #2: required - rollback
jtx = worker.maybeRequestTransaction(required(), CTX_1);
assertNotNull(jtx);
session = sessionProvider.getDbSession();
executeUpdate(session, "insert into GIRL values(2, 'Gloria', null)");
assertTrue(worker.markOrRollbackTransaction(jtx, null));
// test
session = new DbSession(cp);
assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 1"));
assertEquals(0, executeCount(session, "select count(*) from GIRL where id = 2"));