How to get the result of the transaction
What is the way to know if the transaction has been commited or rolled back after the
Code:
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
//..
});block?
See the TransactionTemplate javadoc:
Execute the action specified by the given callback object within a transaction. Allows for returning a result object created within the transaction, i.e. a domain object or a collection of domain objects. A RuntimeException thrown by the callback is treated as application exception that enforces a rollback. An exception gets propagated to the caller of the template.
Parameters:action - callback object that specifies the transactional action Returns:a result object returned by the callback, or null Throws: TransactionException - in case of initialization, rollback, or system errors
Hello,
does it mean when the execute method returns there is a guarantee that the specified transaction has committed successfully?
Thanks,
Farzad-
You can always have a look at the code, it's open source. If an exception occurs then it's thrown. Hence you get the result of the call if it completes succesfully. |