EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference

javax.persistence
Enum LockModeType

java.lang.Object
  extended by java.lang.Enum<LockModeType>
      extended by javax.persistence.LockModeType
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<LockModeType>

public enum LockModeType
extends java.lang.Enum<LockModeType>

Six lock mode types are defined: OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, PESSIMISTIC_FORCE_INCREMENT, NONE. The lock mode type values READ and WRITE are synonyms of OPTIMISTIC and OPTIMISTIC_FORCE_INCREMENT respectively. The latter are to be preferred for new applications.

Lock modes OPTIMISTIC and OPTIMISTIC_FORCE_INCREMENT are used for optimistic locking. The semantics of requesting locks of type LockModeType.OPTIMISTIC and LockMode- Type.OPTIMISTIC_FORCE_INCREMENT are the following.

If transaction T1 calls lock(entity, LockModeType.OPTIMISTIC) on a versioned object, the entity manager must ensure that neither of the following phenomena can occur:

Lock modes PESSIMISTIC_READ, PESSIMISTIC_WRITE, and PESSIMISTIC_FORCE_INCREMENT are used to immediately obtain long-term database locks. The semantics of requesting locks of type LockModeType.PESSIMISTIC_READ, LockMode- Type.PESSIMISTIC_WRITE, and LockModeType.PESSIMISTIC_FORCE_INCREMENT are the following.

If transaction T1 calls lock(entity, LockModeType.PESSIMISTIC_READ) or lock(entity, LockModeType.PESSIMISTIC_WRITE)on an object, the entity manager must ensure that neither of the following phenomena can occur:

Any such lock must be obtained immediately and retained until transaction T1 completes (commits or rolls back).

See Also:
EntityManager.find(Class, Object, LockModeType), EntityManager.find(Class, Object, LockModeType, java.util.Map), EntityManager.getLockMode(Object), EntityManager.lock(Object, LockModeType), EntityManager.lock(Object, LockModeType, java.util.Map), EntityManager.refresh(Object, LockModeType), EntityManager.refresh(Object, LockModeType, java.util.Map), NamedQuery.lockMode(), Query.getLockMode()
Since:
Java Persistence 2.0

Enum Constant Summary
NONE
          No locking
OPTIMISTIC
          Equivalent to READ lock
OPTIMISTIC_FORCE_INCREMENT
          Equivalent to WRITE lock
PESSIMISTIC_FORCE_INCREMENT
           
PESSIMISTIC_READ
           
PESSIMISTIC_WRITE
           
READ
          Read lock READ is synonymous with OPTIMISTIC.
WRITE
          Write lock WRITE is synonymous with OPTIMISTIC_FORCE_INCREMENT.
 
Method Summary
static LockModeType valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static LockModeType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

READ

public static final LockModeType READ
Read lock READ is synonymous with OPTIMISTIC.


WRITE

public static final LockModeType WRITE
Write lock WRITE is synonymous with OPTIMISTIC_FORCE_INCREMENT.


OPTIMISTIC

public static final LockModeType OPTIMISTIC
Equivalent to READ lock

Since:
Java Persistence 2.0

OPTIMISTIC_FORCE_INCREMENT

public static final LockModeType OPTIMISTIC_FORCE_INCREMENT
Equivalent to WRITE lock

Since:
Java Persistence 2.0

PESSIMISTIC_READ

public static final LockModeType PESSIMISTIC_READ
Since:
Java Persistence 2.0

PESSIMISTIC_WRITE

public static final LockModeType PESSIMISTIC_WRITE
Since:
Java Persistence 2.0

PESSIMISTIC_FORCE_INCREMENT

public static final LockModeType PESSIMISTIC_FORCE_INCREMENT
Since:
Java Persistence 2.0

NONE

public static final LockModeType NONE
No locking

Since:
Java Persistence 2.0
Method Detail

values

public static LockModeType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (LockModeType c : LockModeType.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static LockModeType valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

EclipseLink 2.0.0_ 2.0.0.v20090626-r4569 API Reference