Interface TransactionFinalizer

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface TransactionFinalizer
Outer transaction hook called last: after the transaction is committed or rolled back and before the connection returns to the pool. A convenient place to finish metrics, tracing or logging.

Called whenever TransactionInitializer succeeded, and sees the final outcome, including failures of SqlInitializer and of the commit itself:

  • committed — Ok of the transaction result (None for null); an exception from this finalizer cannot undo the commit, so it is logged and ignored, and the caller receives the result;
  • rolled back — Err of the exception; the caller receives it, and an exception from this finalizer is added to it as suppressed.
The database transaction is already finished, so queries through sql are not allowed; metadata such as Sql.readOnly() is available.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Finalizer that does nothing.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    done(Sql sql, Result<Option<Object>, Throwable> outcome)
    Completes the outer scope of the transaction after commit or rollback.
  • Field Details

  • Method Details

    • done

      void done(Sql sql, Result<Option<Object>, Throwable> outcome)
      Completes the outer scope of the transaction after commit or rollback.
      Parameters:
      sql - database access of the transaction (queries are no longer allowed)
      outcome - the transaction result if committed (None for null), the exception that rolled it back otherwise