Annotation Interface InTransaction


@Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface InTransaction
Annotation for unit of work and transaction declaration. Code executed under the scope of annotation will share the same transaction (and handle).

Use on class to mark all methods as transactional.

Support nesting: nested annotated elements will participate in outer transaction (and so exceptions will rollback entire transaction). If nested transaction configuration contradict with ongoing transaction then exception will be thrown (e.g. different isolation level or write required under read only transaction).

NOTE: jdbi transaction annotation (Transaction) is not used to avoid internal jdbi transaction handling mechanism which may contradict with guice-central transactional mechanism (because simply jdbi is not aware of it and did not expect anyone to manage transaction instead).

Since:
31.08.2018
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Set the connection readOnly property before the transaction starts, and restore it before it returns.
    org.jdbi.v3.core.transaction.TransactionIsolationLevel
     
  • Element Details

    • value

      org.jdbi.v3.core.transaction.TransactionIsolationLevel value
      Returns:
      the transaction isolation level. If not specified, invoke with the default isolation level.
      Default:
      UNKNOWN
    • readOnly

      boolean readOnly
      Set the connection readOnly property before the transaction starts, and restore it before it returns. Databases may use this as a performance or concurrency hint.
      Returns:
      whether the transaction is read only
      Default:
      false