接口 TransactionDefine

所有已知实现类:
DefaultTransactionDefine

public interface TransactionDefine
  • 嵌套类概要

    嵌套类
    修饰符和类型
    接口
    说明
    static enum 
     
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final int
    Use the default isolation level of the underlying datastore.
    static final int
    Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
    static final int
    Indicates that dirty reads, non-repeatable reads and phantom reads can occur.
    static final int
    Indicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
    static final int
    Indicates that dirty reads, non-repeatable reads and phantom reads are prevented.
    static final int
    如果当前存在事务,则加入该事务;如果当前没有事务,则抛出异常。
    static final int
    如果当前存在事务,则创建一个事务作为当前事务的嵌套事务来运行;如果当前没有事务,则该取值等价于TransactionDefinition.PROPAGATION_REQUIRED。
    static final int
    以非事务方式运行,如果当前存在事务,则抛出异常。
    static final int
    以非事务方式运行,如果当前存在事务,则把当前事务挂起。
    static final int
    如果当前存在事务,则加入该事务;如果当前没有事务,则创建一个新的事务
    static final int
    创建一个新的事务,如果当前存在事务,则把当前事务挂起。
    static final int
    如果当前存在事务,则加入该事务;如果当前没有事务,则以非事务的方式继续运行。
    static final int
    Use the default timeout of the underlying transaction system, or none if timeouts are not supported.
  • 方法概要

    修饰符和类型
    方法
    说明
    default int
    Return the isolation level.
     
    default String
    Return the name of this transaction.
    default int
    Return the propagation behavior.
     
    default int
    Return the transaction timeout.
    default boolean
    Return whether to optimize as a read-only transaction.
    void
     
    void
     
    void
    setReadOnly(boolean readOnly)
     
    void
    setTimeout(int timeout)
     
  • 字段详细资料

    • PROPAGATION_REQUIRED

      static final int PROPAGATION_REQUIRED
      如果当前存在事务,则加入该事务;如果当前没有事务,则创建一个新的事务
      另请参阅:
    • PROPAGATION_SUPPORTS

      static final int PROPAGATION_SUPPORTS
      如果当前存在事务,则加入该事务;如果当前没有事务,则以非事务的方式继续运行。
      另请参阅:
    • PROPAGATION_MANDATORY

      static final int PROPAGATION_MANDATORY
      如果当前存在事务,则加入该事务;如果当前没有事务,则抛出异常。
      另请参阅:
    • PROPAGATION_REQUIRES_NEW

      static final int PROPAGATION_REQUIRES_NEW
      创建一个新的事务,如果当前存在事务,则把当前事务挂起。
      另请参阅:
    • PROPAGATION_NOT_SUPPORTED

      static final int PROPAGATION_NOT_SUPPORTED
      以非事务方式运行,如果当前存在事务,则把当前事务挂起。
      另请参阅:
    • PROPAGATION_NEVER

      static final int PROPAGATION_NEVER
      以非事务方式运行,如果当前存在事务,则抛出异常。
      另请参阅:
    • PROPAGATION_NESTED

      static final int PROPAGATION_NESTED
      如果当前存在事务,则创建一个事务作为当前事务的嵌套事务来运行;如果当前没有事务,则该取值等价于TransactionDefinition.PROPAGATION_REQUIRED。
      另请参阅:
    • ISOLATION_DEFAULT

      static final int ISOLATION_DEFAULT
      Use the default isolation level of the underlying datastore. All other levels correspond to the JDBC isolation levels.
      另请参阅:
    • ISOLATION_READ_UNCOMMITTED

      static final int ISOLATION_READ_UNCOMMITTED
      Indicates that dirty reads, non-repeatable reads and phantom reads can occur.

      This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read"). If any of the changes are rolled back, the second transaction will have retrieved an invalid row.

      另请参阅:
    • ISOLATION_READ_COMMITTED

      static final int ISOLATION_READ_COMMITTED
      Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.

      This level only prohibits a transaction from reading a row with uncommitted changes in it.

      另请参阅:
    • ISOLATION_REPEATABLE_READ

      static final int ISOLATION_REPEATABLE_READ
      Indicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.

      This level prohibits a transaction from reading a row with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the first transaction re-reads the row, getting different values the second time (a "non-repeatable read").

      另请参阅:
    • ISOLATION_SERIALIZABLE

      static final int ISOLATION_SERIALIZABLE
      Indicates that dirty reads, non-repeatable reads and phantom reads are prevented.

      This level includes the prohibitions in ISOLATION_REPEATABLE_READ and further prohibits the situation where one transaction reads all rows that satisfy a WHERE condition, a second transaction inserts a row that satisfies that WHERE condition, and the first transaction re-reads for the same condition, retrieving the additional "phantom" row in the second read.

      另请参阅:
    • TIMEOUT_DEFAULT

      static final int TIMEOUT_DEFAULT
      Use the default timeout of the underlying transaction system, or none if timeouts are not supported.
      另请参阅:
  • 方法详细资料

    • getPropagationBehavior

      default int getPropagationBehavior()
      Return the propagation behavior.

      Must return one of the PROPAGATION_XXX constants

      The default is PROPAGATION_REQUIRED.

      返回:
      the propagation behavior
      另请参阅:
    • getPropagationBehaviorName

      String getPropagationBehaviorName()
    • getIsolationLevel

      default int getIsolationLevel()
      Return the isolation level.

      Must return one of the ISOLATION_XXX constants defined on

      Exclusively designed for use with PROPAGATION_REQUIRED or transactions. Consider switching the "validateExistingTransactions" flag to "true" on your transaction manager if you'd like isolation level declarations to get rejected when participating in an existing transaction with a different isolation level.

      The default is ISOLATION_DEFAULT. Note that a transaction manager that does not support custom isolation levels will throw an exception when given any other level than ISOLATION_DEFAULT.

      返回:
      the isolation level
    • setTimeout

      void setTimeout(int timeout)
    • getTimeout

      default int getTimeout()
      Return the transaction timeout.

      Must return a number of seconds, or TIMEOUT_DEFAULT.

      Exclusively designed for use with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW since it only applies to newly started transactions.

      Note that a transaction manager that does not support timeouts will throw an exception when given any other timeout than TIMEOUT_DEFAULT.

      The default is TIMEOUT_DEFAULT.

      返回:
      the transaction timeout
    • setReadOnly

      void setReadOnly(boolean readOnly)
    • isReadOnly

      default boolean isReadOnly()
      Return whether to optimize as a read-only transaction.

      The read-only flag applies to any transaction context, whether backed by an actual resource transaction (PROPAGATION_REQUIRED/ PROPAGATION_REQUIRES_NEW) or operating non-transactionally at the resource level (PROPAGATION_SUPPORTS). In the latter case, the flag will only apply to managed resources within the application, such as a Hibernate Session.

      This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.

      返回:
      true if the transaction is to be optimized as read-only (false by default)
    • getName

      default String getName()
      Return the name of this transaction. Can be null.

      This will be used as the transaction name to be shown in a transaction monitor, if applicable (for example, WebLogic's).

      In case of Spring's declarative transactions, the exposed name will be the fully-qualified class name + "." + method name (by default).

      返回:
      the name of this transaction (null by default}
    • setName

      void setName(String name)
    • getMode

      default TransactionDefine.MODE getMode()
    • setMode

      void setMode(TransactionDefine.MODE mode)