Enum TxType

java.lang.Object
java.lang.Enum<TxType>
io.ebean.annotation.TxType
All Implemented Interfaces:
Serializable, Comparable<TxType>

public enum TxType extends Enum<TxType>
Used to define the transactional scope for executing a method. Matches the types defined in the EJB TransactionAttributeType.

Used with the Transactional annotation and TxScope with

  • Ebean execute(TxScope, Runnable)
  • Ebean executeCall(TxScope, Callable)

  • Enum Constant Details

    • REQUIRED

      public static final TxType REQUIRED
      Uses an existing transaction and if none exists will starts a new Transaction. This is the default.
    • MANDATORY

      public static final TxType MANDATORY
      A transaction MUST already have been started. Throws TransactionRequiredException.
    • SUPPORTS

      public static final TxType SUPPORTS
      Uses the existing transaction if one exists, otherwise the method does not run with a transaction. Used this with caution.
    • REQUIRES_NEW

      public static final TxType REQUIRES_NEW
      Always start a new transaction. Suspend an existing once if required.
    • NOT_SUPPORTED

      public static final TxType NOT_SUPPORTED
      Suspends an existing transaction if required. Method runs without a transaction.
    • NEVER

      public static final TxType NEVER
      If there is an existing transaction throws an Exception. Method runs without a transaction.
  • Method Details

    • values

      public static TxType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static TxType valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null