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 Transaction |
beginTransaction() |
<T> T |
execute(Callable<T> work)
Defaults to required() strategy.
|
TransactionTemplate |
mandatory() |
TransactionTemplate |
nested() |
TransactionTemplate |
never() |
TransactionTemplate |
notSupported() |
TransactionTemplate |
required() |
TransactionTemplate |
requiresNew() |
TransactionTemplate |
supports() |
TransactionTemplate |
withTimeout(int timeout) |
protected TransactionManager utm
public TransactionTemplate withTimeout(int timeout)
public TransactionTemplate required()
public TransactionTemplate nested()
protected Transaction beginTransaction() 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 © 2023. All rights reserved.