Search in sources :

Example 21 with JtxTransaction

use of jodd.jtx.JtxTransaction in project jodd by oblac.

the class LeanJtxWorker method maybeRequestTransaction.

/**
	 * Requests for transaction and returns non-null value <b>only</b> when new transaction
	 * is created! When <code>null</code> is returned, transaction may be get by
	 * {@link #getCurrentTransaction()}.
	 *
	 * @see jodd.jtx.JtxTransactionManager#requestTransaction(jodd.jtx.JtxTransactionMode)
	 */
public JtxTransaction maybeRequestTransaction(JtxTransactionMode txMode, Object scope) {
    if (txMode == null) {
        return null;
    }
    JtxTransaction currentTx = txManager.getTransaction();
    JtxTransaction requestedTx = txManager.requestTransaction(txMode, scope);
    if (currentTx == requestedTx) {
        return null;
    }
    return requestedTx;
}
Also used : JtxTransaction(jodd.jtx.JtxTransaction)

Aggregations

JtxTransaction (jodd.jtx.JtxTransaction)21 Test (org.junit.Test)18 DbJtxSessionProvider (jodd.db.jtx.DbJtxSessionProvider)13 LeanJtxWorker (jodd.jtx.worker.LeanJtxWorker)13 DbJtxTransaction (jodd.db.jtx.DbJtxTransaction)5 JtxTransactionMode (jodd.jtx.JtxTransactionMode)5 DbJtxResourceManager (jodd.db.jtx.DbJtxResourceManager)4 JtxException (jodd.jtx.JtxException)4 JtxTransactionManager (jodd.jtx.JtxTransactionManager)4 SQLException (java.sql.SQLException)1 AppDao (jodd.joy.db.AppDao)1 Madvoc (jodd.madvoc.Madvoc)1 ProxyTarget.targetClass (jodd.proxetta.ProxyTarget.targetClass)1