org.datanucleus
Interface UserTransaction


public interface UserTransaction

UserTransaction is the interface exposed by JPOX to User Applications. It allows proprietary JPOX extensions to be used by user applications. To exemplify the usage of this interface, the below is a JDO snippet: Transaction tx = pm.currentTransaction(); ((UserTransaction)tx).setUseUpdateLock(true); This interface does not make any distinction between user APIs, such as JDO or JPA, neither the datastores, such as RDBMS or DB4O. Unsupported operations will throw UnsupportedOperationException. User applications must be aware that the behaviour of this interface and effects caused by invoking these operations may not be portable between different datastores kinds (RBDMS, DB4O, LDAP, etc )or datastores of same kind (RDBMS Oracle, RDBMS DB2, RDBMS MySQL, RDBMS Derby, etc).


Field Summary
static int TRANSACTION_NONE
          A constant indicating that transactions are not supported.
static int TRANSACTION_READ_COMMITTED
          A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
static int TRANSACTION_READ_UNCOMMITTED
          A constant indicating that dirty reads, non-repeatable reads and phantom reads can occur.
static int TRANSACTION_REPEATABLE_READ
          A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
static int TRANSACTION_SERIALIZABLE
          A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented.
 
Method Summary
 void setTransactionIsolation(int isolation)
          Configure isolation level for the transaction Some datastores do not support Isolation Level feature, and for such datastores this setting is silently ignored.
 void setUseUpdateLock(boolean lock)
          Turn on/off serialized access to data fetch from datastore.
 void useUpdateLockOnFetch()
          Turn on serialized access to data fetch from datastore.
 

Field Detail

TRANSACTION_NONE

static final int TRANSACTION_NONE
A constant indicating that transactions are not supported.

See Also:
Constant Field Values

TRANSACTION_READ_UNCOMMITTED

static final int TRANSACTION_READ_UNCOMMITTED
A constant indicating 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.

See Also:
Constant Field Values

TRANSACTION_READ_COMMITTED

static final int TRANSACTION_READ_COMMITTED
A constant indicating 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.

See Also:
Constant Field Values

TRANSACTION_REPEATABLE_READ

static final int TRANSACTION_REPEATABLE_READ
A constant indicating 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 rereads the row, getting different values the second time (a "non-repeatable read").

See Also:
Constant Field Values

TRANSACTION_SERIALIZABLE

static final int TRANSACTION_SERIALIZABLE
A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented. This level includes the prohibitions in TRANSACTION_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 rereads for the same condition, retrieving the additional "phantom" row in the second read.

See Also:
Constant Field Values
Method Detail

useUpdateLockOnFetch

void useUpdateLockOnFetch()
Turn on serialized access to data fetch from datastore. Calling this in the middle of a transaction will only affect data read after it. Some datastores do not support Update Lock feature, and for such datastores this setting is silently ignored.


setUseUpdateLock

void setUseUpdateLock(boolean lock)
Turn on/off serialized access to data fetch from datastore. Calling this in the middle of a transaction will only affect data read after it. Some datastores do not support Update Lock feature, and for such datastores this setting is silently ignored.

Parameters:
lock - whether to lock data or not

setTransactionIsolation

void setTransactionIsolation(int isolation)
Configure isolation level for the transaction Some datastores do not support Isolation Level feature, and for such datastores this setting is silently ignored. Calling this in the middle of a transaction has behaviour undetermined

Parameters:
isolation - level


Copyright © 2011. All Rights Reserved.