Annotation Type Transactional


@Retention(RUNTIME) @Target({METHOD,TYPE}) public @interface Transactional
Any method marked with this annotation will be considered for transactionality.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The TxType element of the annotation indicates whether a bean method is to be executed within a transaction context where the values provide the following corresponding behavior.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Deprecated.
    Users that intend auto commit can achieve it by simply not using @Transactional
    A custom error message when throwing the custom exception.
    org.apache.ibatis.session.ExecutorType
    Returns the constant indicating the myBatis executor type.
    boolean
    Flag to indicate that myBatis has to force the transaction commit().
    Returns the constant indicating the transaction isolation level.
    org.apache.ibatis.session.TransactionIsolationLevel
    Deprecated.
    use isolation() instead, setting this property has no effect.
    Class<? extends Throwable>
    The exception re-thrown when an error occurs during the transaction.
    boolean
    If true, the transaction will never committed but rather rolled back, useful for testing purposes.
    The TxType element of the Transactional annotation indicates whether a bean method is to be executed within a transaction context.
  • Element Details

    • executorType

      org.apache.ibatis.session.ExecutorType executorType
      Returns the constant indicating the myBatis executor type.
      Returns:
      the constant indicating the myBatis executor type.
      Default:
      SIMPLE
    • isolation

      Isolation isolation
      Returns the constant indicating the transaction isolation level.
      Returns:
      the constant indicating the transaction isolation level.
      Default:
      DEFAULT
    • isolationLevel

      @Deprecated org.apache.ibatis.session.TransactionIsolationLevel isolationLevel
      Deprecated.
      use isolation() instead, setting this property has no effect.
      Returns the constant indicating the transaction isolation level.
      Returns:
      the constant indicating the transaction isolation level.
      Default:
      NONE
    • force

      boolean force
      Flag to indicate that myBatis has to force the transaction commit().
      Returns:
      false by default, user defined otherwise.
      Default:
      false
    • autoCommit

      @Deprecated boolean autoCommit
      Deprecated.
      Users that intend auto commit can achieve it by simply not using @Transactional
      Flag to indicate the auto commit policy.
      Returns:
      false by default, user defined otherwise.
      Default:
      false
    • rethrowExceptionsAs

      Class<? extends Throwable> rethrowExceptionsAs
      The exception re-thrown when an error occurs during the transaction.
      Returns:
      the exception re-thrown when an error occurs during the transaction.
      Default:
      java.lang.Exception.class
    • exceptionMessage

      String exceptionMessage
      A custom error message when throwing the custom exception.

      It supports java.util.Formatter place holders, intercepted method arguments will be used as message format arguments.

      Returns:
      a custom error message when throwing the custom exception.
      See Also:
      Default:
      ""
    • rollbackOnly

      boolean rollbackOnly
      If true, the transaction will never committed but rather rolled back, useful for testing purposes.

      This parameter is false by default.

      Returns:
      if true, the transaction will never committed but rather rolled back, useful for testing purposes.
      Default:
      false
    • value

      The TxType element of the Transactional annotation indicates whether a bean method is to be executed within a transaction context.
      Returns:
      the tx type
      Default:
      REQUIRED