@Singleton
public class TransactionTemplate
extends java.lang.Object
Usage:
@Inject TransactionTemplate template;
...
template.inTransaction(() -> doSoemStaff())
| Constructor and Description |
|---|
TransactionTemplate(UnitManager manager) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
inTransaction(TxAction<T> action)
Wraps provided action with unit of work and transaction.
|
@Inject public TransactionTemplate(UnitManager manager)
public <T> T inTransaction(TxAction<T> action)
NOTE: If unit of work was started manually (using UnitManager, but without transaction started,
then action will be simply executed without starting transaction. This was done for rare situations
when logic must be performed without transaction and transaction annotation will simply indicate unit of work.
T - return typeaction - action to execute