public interface TransactionDefine
| 限定符和类型 | 接口和说明 |
|---|---|
static class |
TransactionDefine.MODE |
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
ISOLATION_DEFAULT
Use the default isolation level of the underlying datastore.
|
static int |
ISOLATION_READ_COMMITTED
Indicates that dirty reads are prevented; non-repeatable reads and
phantom reads can occur.
|
static int |
ISOLATION_READ_UNCOMMITTED
Indicates that dirty reads, non-repeatable reads and phantom reads
can occur.
|
static int |
ISOLATION_REPEATABLE_READ
Indicates that dirty reads and non-repeatable reads are prevented;
phantom reads can occur.
|
static int |
ISOLATION_SERIALIZABLE
Indicates that dirty reads, non-repeatable reads and phantom reads
are prevented.
|
static int |
PROPAGATION_MANDATORY
如果当前存在事务,则加入该事务;如果当前没有事务,则抛出异常。
|
static int |
PROPAGATION_NESTED
如果当前存在事务,则创建一个事务作为当前事务的嵌套事务来运行;如果当前没有事务,则该取值等价于TransactionDefinition.PROPAGATION_REQUIRED。
|
static int |
PROPAGATION_NEVER
以非事务方式运行,如果当前存在事务,则抛出异常。
|
static int |
PROPAGATION_NOT_SUPPORTED
以非事务方式运行,如果当前存在事务,则把当前事务挂起。
|
static int |
PROPAGATION_REQUIRED
如果当前存在事务,则加入该事务;如果当前没有事务,则创建一个新的事务
|
static int |
PROPAGATION_REQUIRES_NEW
创建一个新的事务,如果当前存在事务,则把当前事务挂起。
|
static int |
PROPAGATION_SUPPORTS
如果当前存在事务,则加入该事务;如果当前没有事务,则以非事务的方式继续运行。
|
static int |
TIMEOUT_DEFAULT
Use the default timeout of the underlying transaction system,
or none if timeouts are not supported.
|
| 限定符和类型 | 方法和说明 |
|---|---|
default int |
getIsolationLevel()
Return the isolation level.
|
default TransactionDefine.MODE |
getMode() |
default String |
getName()
Return the name of this transaction.
|
default int |
getPropagationBehavior()
Return the propagation behavior.
|
String |
getPropagationBehaviorName() |
default int |
getTimeout()
Return the transaction timeout.
|
default boolean |
isReadOnly()
Return whether to optimize as a read-only transaction.
|
void |
setMode(TransactionDefine.MODE mode) |
void |
setName(String name) |
void |
setReadOnly(boolean readOnly) |
void |
setTimeout(int timeout) |
static final int PROPAGATION_REQUIRED
static final int PROPAGATION_SUPPORTS
static final int PROPAGATION_MANDATORY
static final int PROPAGATION_REQUIRES_NEW
static final int PROPAGATION_NOT_SUPPORTED
static final int PROPAGATION_NEVER
static final int PROPAGATION_NESTED
static final int ISOLATION_DEFAULT
Connection,
常量字段值static final int ISOLATION_READ_UNCOMMITTED
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.
static final int ISOLATION_READ_COMMITTED
This level only prohibits a transaction from reading a row with uncommitted changes in it.
static final int ISOLATION_REPEATABLE_READ
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").
static final int ISOLATION_SERIALIZABLE
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.
static final int TIMEOUT_DEFAULT
default int getPropagationBehavior()
Must return one of the PROPAGATION_XXX constants
The default is PROPAGATION_REQUIRED.
PROPAGATION_REQUIREDString getPropagationBehaviorName()
default int getIsolationLevel()
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.
void setTimeout(int timeout)
default int getTimeout()
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.
void setReadOnly(boolean readOnly)
default boolean isReadOnly()
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)default String getName()
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).
null by default}void setName(String name)
default TransactionDefine.MODE getMode()
void setMode(TransactionDefine.MODE mode)
Copyright © 2024. All rights reserved.