public class TransactionTemplate
extends java.lang.Object
TransactionTemplate template = new TransactionTemplate();
template.withTimeout(5).required().execute(() -> {
//your transactional code as a lambda expression
});
Instead of a lambda expression, you can also supply a Callable instance.| Modifier and Type | Field and Description |
|---|---|
protected javax.transaction.TransactionManager |
utm |
| Constructor and Description |
|---|
TransactionTemplate() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beginTransaction() |
protected void |
beginTransactionIfNoneExists() |
protected void |
commitTransactionIfStartedHere() |
<T> T |
execute(java.util.concurrent.Callable<T> work)
Defaults to required() strategy.
|
protected void |
forceRollback(java.lang.Throwable e) |
TransactionTemplate |
mandatory() |
TransactionTemplate |
nested() |
TransactionTemplate |
never() |
TransactionTemplate |
notSupported() |
TransactionTemplate |
required() |
TransactionTemplate |
requiresNew() |
protected void |
resumeExistingTransaction() |
TransactionTemplate |
supports() |
protected void |
suspendExistingTransaction() |
TransactionTemplate |
withTimeout(int timeout) |
public TransactionTemplate withTimeout(int timeout)
public TransactionTemplate required()
public TransactionTemplate nested()
protected void beginTransaction()
throws java.lang.Exception
java.lang.Exceptionprotected void commitTransactionIfStartedHere()
throws java.lang.Exception
java.lang.Exceptionprotected void forceRollback(java.lang.Throwable e)
throws java.lang.Exception
java.lang.Exceptionprotected void beginTransactionIfNoneExists()
throws java.lang.Exception
java.lang.Exceptionprotected void resumeExistingTransaction()
throws java.lang.Exception
java.lang.Exceptionprotected void suspendExistingTransaction()
throws java.lang.Exception
java.lang.Exceptionpublic <T> T execute(java.util.concurrent.Callable<T> work)
throws java.lang.Exception
work - java.lang.Exceptionpublic TransactionTemplate requiresNew()
public TransactionTemplate mandatory()
public TransactionTemplate never()
public TransactionTemplate supports()
public TransactionTemplate notSupported()
Copyright © 2020. All Rights Reserved.