public class TransactionTemplate extends 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 TransactionManager |
utm |
| Constructor and Description |
|---|
TransactionTemplate() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beginTransaction() |
protected void |
beginTransactionIfNoneExists() |
protected void |
commitTransactionIfStartedHere() |
<T> T |
execute(Callable<T> work)
Defaults to required() strategy.
|
protected void |
forceRollback(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) |
protected TransactionManager utm
public TransactionTemplate withTimeout(int timeout)
public TransactionTemplate required()
public TransactionTemplate nested()
protected void commitTransactionIfStartedHere()
throws Exception
Exceptionprotected void beginTransactionIfNoneExists()
throws Exception
Exceptionprotected void resumeExistingTransaction()
throws Exception
Exceptionprotected void suspendExistingTransaction()
throws Exception
Exceptionpublic <T> T execute(Callable<T> work) throws Exception
work - Exceptionpublic TransactionTemplate requiresNew()
public TransactionTemplate mandatory()
public TransactionTemplate never()
public TransactionTemplate supports()
public TransactionTemplate notSupported()
Copyright © 2022. All rights reserved.