接口 TransactionDefine
- 所有已知实现类:
DefaultTransactionDefine
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明static final intUse the default isolation level of the underlying datastore.static final intIndicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.static final intIndicates that dirty reads, non-repeatable reads and phantom reads can occur.static final intIndicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.static final intIndicates 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 intUse the default timeout of the underlying transaction system, or none if timeouts are not supported. -
方法概要
修饰符和类型方法说明default intReturn the isolation level.default TransactionDefine.MODEgetMode()default StringgetName()Return the name of this transaction.default intReturn the propagation behavior.default intReturn the transaction timeout.default booleanReturn whether to optimize as a read-only transaction.voidvoidvoidsetReadOnly(boolean readOnly) voidsetTimeout(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_DEFAULTUse 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_UNCOMMITTEDIndicates 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_COMMITTEDIndicates 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_READIndicates 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_SERIALIZABLEIndicates that dirty reads, non-repeatable reads and phantom reads are prevented.This level includes the prohibitions in
ISOLATION_REPEATABLE_READand further prohibits the situation where one transaction reads all rows that satisfy aWHEREcondition, a second transaction inserts a row that satisfies thatWHEREcondition, 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_DEFAULTUse 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_XXXconstantsThe default is
PROPAGATION_REQUIRED.- 返回:
- the propagation behavior
- 另请参阅:
-
getPropagationBehaviorName
String getPropagationBehaviorName() -
getIsolationLevel
default int getIsolationLevel()Return the isolation level.Must return one of the
ISOLATION_XXXconstants defined onExclusively designed for use with
PROPAGATION_REQUIREDor 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 thanISOLATION_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_REQUIREDorPROPAGATION_REQUIRES_NEWsince 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 HibernateSession.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.
- 返回:
trueif the transaction is to be optimized as read-only (falseby default)
-
getName
Return the name of this transaction. Can benull.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 (
nullby default}
-
setName
-
getMode
-
setMode
-