Interface TransactionCompletion


  • public interface TransactionCompletion
    A mutable object that controls whether a transactionCompletion Operation sends a database commit or a database rollback to the server. A transactionCompletion Operation is created with a TransactionCompletion. By default a transactionCompletion Operation requests that the database end the transaction with a commit. If setRollbackOnly() is called on the TransactionCompletion used to create the Operation prior to the Operation being executed, the Operation will request that the database end the transaction with a rollback. Example:
     
     TransactionCompletion t = session.transactionCompletion();
     session.countOperation(updateSql)
     .resultProcessor( count -> { if (count > 1) t.setRollbackOnly(); } )
     .submit();
     session.commitMaybeRollback(t);
     
    A TransactionCompletion can not be used to create more than one endTransaction Operation. A TransactionCompletion is thread safe.
    • Method Detail

      • setRollbackOnly

        boolean setRollbackOnly()
        Causes an endTransaction Operation created with this TransactionCompletion that is executed subsequent to this call to perform a rollback. If this method is not called prior to Operation execution the Operation will perform a commit.
        Returns:
        true if the call succeeded. false if the call did not succeed in setting the TransactionCompletion rollback only because the endTransaction Operation had already been executed.
      • isRollbackOnly

        boolean isRollbackOnly()
        Returns true iff the setRollbackOnly() method has been called on this TransactionCompletion
        Returns:
        true if setRollbackOnly() has been called.