接口 TransactionOperations

  • 所有已知实现类:
    TransactionTemplate

    public interface TransactionOperations
    Interface specifying basic transaction execution operations. Implemented by TransactionTemplate. Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.
    从以下版本开始:
    2.0.4
    作者:
    Juergen Hoeller
    • 方法详细资料

      • execute

        <T> T execute​(TransactionCallback<T> action)
               throws TransactionException
        Execute the action specified by the given callback object within a transaction.

        Allows for returning a result object created within the transaction, that is, a domain object or a collection of domain objects. 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.

        参数:
        action - the callback object that specifies the transactional action
        返回:
        a result object returned by the callback, or null if none
        抛出:
        TransactionException - in case of initialization, rollback, or system errors
        RuntimeException - if thrown by the TransactionCallback