|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
Object Enum<TxIsolationLevel> hirondelle.web4j.database.TxIsolationLevel
public enum TxIsolationLevel
Type-safe enumeration for transaction isolation levels.
For more information on transaction isolation levels, see Connection
and the
wikipedia
article.
See TxTemplate
, which is closely related to this class.
In order of decreasing strictness (and increasing performance), the levels are :
In addition, this class includes another item called DATABASE_DEFAULT. It indicates to the WEB4J data layer that, unless instructed otherwise, the default isolation level defined by the database instance is to be used.
If a SELECT is repeated in a given transaction, it may see a different ResultSet, since some second transaction may have committed changes to the underlying data. Three questions can be asked of the second ResultSet, and each isolation level responds to these three questions in a different way :
Level | 1. Can a new record appear? | 2. Can an old record disappear? | 3. Can an old record change? |
---|---|---|---|
SERIALIZABLE | Never | Never | Never |
REPEATABLE_READ | Possibly | Never | Never |
READ_COMMITTED | Possibly | Possibly | Possibly |
(Note : 1 is called a phantom read, while both 2 and 3 are called a non-repeatable read.)
set(hirondelle.web4j.database.TxIsolationLevel, java.sql.Connection)
for some help in this regard). The DATABASE_DEFAULT
setting is an attempt to hide these variations in support
DB2 | MySQL | Oracle | PostgreSQL | SQL Server | |
SERIALIZABLE | Y | Y | Y | Y | Y |
REPEATABLE_READ | Y | Y* | N | N | Y |
READ_COMMITTED | Y | Y | Y* | Y* | Y* |
READ_UNCOMMITTED | Y | Y | N | N | Y |
Enum Constant Summary | |
---|---|
DATABASE_DEFAULT
|
|
READ_COMMITTED
|
|
READ_UNCOMMITTED
|
|
REPEATABLE_READ
|
|
SERIALIZABLE
|
Method Summary | |
---|---|
int |
getInt()
Return the same underlying int value used by Connection to identify the isolation level. |
static void |
set(TxIsolationLevel aLevel,
Connection aConnection)
Set a particular isolation level for aConnection. |
String |
toString()
Return one of the permitted values, including 'DATABASE_DEFAULT'. |
static TxIsolationLevel |
valueOf(String name)
Returns the enum constant of this type with the specified name. |
static TxIsolationLevel[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf |
Methods inherited from class Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final TxIsolationLevel SERIALIZABLE
public static final TxIsolationLevel REPEATABLE_READ
public static final TxIsolationLevel READ_COMMITTED
public static final TxIsolationLevel READ_UNCOMMITTED
public static final TxIsolationLevel DATABASE_DEFAULT
Method Detail |
---|
public static TxIsolationLevel[] values()
for (TxIsolationLevel c : TxIsolationLevel.values()) System.out.println(c);
public static TxIsolationLevel valueOf(String name)
name
- the name of the enum constant to be returned.
IllegalArgumentException
- if this enum type has no constant
with the specified name
NullPointerException
- if the argument is nullpublic int getInt()
Connection
to identify the isolation level.
For DATABASE_DEFAULT
, return -1.
public String toString()
toString
in class Enum<TxIsolationLevel>
public static void set(TxIsolationLevel aLevel, Connection aConnection)
This method exists because database support for isolation levels varies widely. If any error occurs because aLevel is not supported, then the error will be logged at a SEVERE level, but the application will continue to run. This policy treats isolation levels as important, but non-critical. Porting an application to a database which does not support all levels will not cause an application to fail. The transaction will simply execute at the database's default isolation level.
Passing in the special value DATABASE_DEFAULT
will cause a no-operation.
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |