public class TransactionTemplate extends DefaultTransactionDefinition
ITransactionManager.
The central method is execute(ITransactionCallback), supporting
transactional code that implements the ITransactionCallback interface.
This template handles the transaction lifecycle and possible exceptions such that
neither the ITransactionCallback implementation nor the calling code needs
to explicitly handle transactions.
Subclass DefaultTransactionDefinition to support setting the name of the
transaction and propagation behavior.
ITransactionCallbackPROPAGATION_MANDATORY, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT| Constructor and Description |
|---|
TransactionTemplate(ITransactionManager pTransactionManager)
Construct a new
TransactionTemplate using the given transaction manager. |
TransactionTemplate(ITransactionManager pTransactionManager,
ITransactionDefinition pDefinition)
Construct a new
TransactionTemplate using the given transaction manager. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
execute(ITransactionCallback pAction)
Execute the action specified by the given callback object within an ODI
transaction.
|
getExtendedPersistentContext, getName, getPropagationBehavior, getTimeout, setExtendedEntityManager, setName, setPropagationBehavior, setTimeoutpublic TransactionTemplate(ITransactionManager pTransactionManager)
TransactionTemplate using the given transaction manager.pTransactionManager - the transaction managerpublic TransactionTemplate(ITransactionManager pTransactionManager, ITransactionDefinition pDefinition)
TransactionTemplate using the given transaction manager.pTransactionManager - the transaction managerpDefinition - the transaction definitionpublic java.lang.Object execute(ITransactionCallback pAction)
Allows for returning a result object created within the transaction, that is, an ODI entity or a collection of ODI entities. A RuntimeException thrown by the callback is treated as a fatal exception that enforces a rollback. Such an exception gets propagated to the caller of the template.
pAction - the callback object that specifies the transactional actionnull