Search in sources :

Example 1 with DbJtxTransaction

use of jodd.db.jtx.DbJtxTransaction in project jodd by oblac.

the class DbTransactionTest method service1.

// service #1 REQUIRED
JtxTransaction service1() {
    assertTotals(0, 0);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertTotals(1, 1);
    s1 = tx.requestResource();
    return tx;
}
Also used : DbJtxTransaction(jodd.db.jtx.DbJtxTransaction) JtxTransactionMode(jodd.jtx.JtxTransactionMode)

Example 2 with DbJtxTransaction

use of jodd.db.jtx.DbJtxTransaction in project jodd by oblac.

the class DbTransactionTest method service3_1.

// service #3_1 NOT SUPPORTED
void service3_1(JtxTransaction tx3) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationNotSupported());
    assertNotSame(tx3, tx);
    assertTotals(2, 1);
    assertNotSame(s1, tx.requestResource());
    assertNotSame(s1, tx.requestResource());
    tx.commit();
    assertTotals(1, 1);
}
Also used : DbJtxTransaction(jodd.db.jtx.DbJtxTransaction) JtxTransactionMode(jodd.jtx.JtxTransactionMode)

Example 3 with DbJtxTransaction

use of jodd.db.jtx.DbJtxTransaction in project jodd by oblac.

the class DbTransactionTest method service3.

// service #3 REQUIRED
void service3(JtxTransaction tx1) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertEquals(tx1, tx);
    assertTotals(1, 1);
    assertEquals(s1, tx.requestResource());
    service3_1(tx);
    assertEquals(s1, tx.requestResource());
    assertTotals(1, 1);
}
Also used : DbJtxTransaction(jodd.db.jtx.DbJtxTransaction) JtxTransactionMode(jodd.jtx.JtxTransactionMode)

Example 4 with DbJtxTransaction

use of jodd.db.jtx.DbJtxTransaction in project jodd by oblac.

the class DbTransactionTest method service2.

// service #2 REQUIRES NEW
void service2(JtxTransaction tx1) {
    assertTotals(1, 1);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequiresNew());
    assertTotals(2, 2);
    assertNotSame(tx1, tx);
    assertNotSame(s1, tx.requestResource());
    tx.commit();
    assertTotals(1, 1);
}
Also used : DbJtxTransaction(jodd.db.jtx.DbJtxTransaction) JtxTransactionMode(jodd.jtx.JtxTransactionMode)

Example 5 with DbJtxTransaction

use of jodd.db.jtx.DbJtxTransaction in project jodd by oblac.

the class DbTransactionTest method service0.

void service0() {
    assertTotals(0, 0);
    DbJtxTransaction tx = dbtxm.requestTransaction(new JtxTransactionMode().propagationRequired());
    assertTotals(1, 1);
    s0 = tx.requestResource();
    service0_1(tx);
    tx.commit();
    assertTotals(0, 0);
}
Also used : DbJtxTransaction(jodd.db.jtx.DbJtxTransaction) JtxTransactionMode(jodd.jtx.JtxTransactionMode)

Aggregations

DbJtxTransaction (jodd.db.jtx.DbJtxTransaction)6 JtxTransactionMode (jodd.jtx.JtxTransactionMode)6