Spec-Zone .ru
спецификации, руководства, описания, API


javax.persistence
Перечислимый LockModeType

java.lang.Object
  расширенный java.lang.Enum<LockModeType>
      расширенный javax.persistence.LockModeType
Все Реализованные Интерфейсы:
java.io. Сериализуемый, java.lang. Сопоставимый <LockModeType>

public enum LockModeType
расширяет java.lang. Перечисление <LockModeType>

Режимы блокировки могут быть определены посредством передачи a LockModeType параметр одному из EntityManager методы, которые берут блокировки (lock, find, или refresh) или к Query.setLockMode() или TypedQuery.setLockMode() метод.

Режимы блокировки могут использоваться, чтобы определить или оптимистические или пессимистические блокировки.

Оптимистические блокировки определяются, используя LockModeType.OPTIMISTIC и LockModeType.OPTIMISTIC_FORCE_INCREMENT. Режим блокировки вводит значения LockModeType.READ и LockModeType.WRITE синонимы OPTIMISTIC и OPTIMISTIC_FORCE_INCREMENT соответственно. Последние должны быть предпочтены для новых приложений.

Семантика запроса блокировок типа LockModeType.OPTIMISTIC и LockModeType.OPTIMISTIC_FORCE_INCREMENT are the following.

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

Lock modes must always prevent the phenomena P1 and P2.

In addition, calling a lock of type LockModeType.OPTIMISTIC_FORCE_INCREMENT on a versioned object, will also force an update (increment) to the entity's version column.

The persistence implementation is not required to support the use of optimistic lock modes on non-versioned objects. When it cannot support a such lock call, it must throw the PersistenceException.

The lock modes LockModeType.PESSIMISTIC_READ, LockModeType.PESSIMISTIC_WRITE, and LockModeType.PESSIMISTIC_FORCE_INCREMENT are used to immediately obtain long-term database locks.

The semantics of requesting locks of type LockModeType.PESSIMISTIC_READ, LockModeType.PESSIMISTIC_WRITE, and LockModeType.PESSIMISTIC_FORCE_INCREMENT are the following.

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

A lock with LockModeType.PESSIMISTIC_WRITE can be obtained on an entity instance to force serialization among transactions attempting to update the entity data. A lock with LockModeType.PESSIMISTIC_READ can be used to query data using repeatable-read semantics without the need to reread the data at the end of the transaction to obtain a lock, and without blocking other transactions reading the data. A lock with LockModeType.PESSIMISTIC_WRITE can be used when querying data and there is a high likelihood of deadlock or update failure among concurrent updating transactions.

The persistence implementation must support use of locks of type LockModeType.PESSIMISTIC_READ LockModeType.PESSIMISTIC_WRITE on a non-versioned entity as well as on a versioned entity.

When the lock cannot be obtained, and the database locking failure results in transaction-level rollback, the provider must throw the PessimisticLockException and ensure that the JTA transaction or EntityTransaction has been marked for rollback.

When the lock cannot be obtained, and the database locking failure results in only statement-level rollback, the provider must throw the LockTimeoutException (and must not mark the transaction for rollback).

Since:
Java Persistence 1.0

Enum Constant Summary
НИ ОДИН
          No lock.
ОПТИМИСТИЧНЫЙ
          Optimistic lock.
OPTIMISTIC_FORCE_INCREMENT
          Optimistic lock, with version update.
PESSIMISTIC_FORCE_INCREMENT
          Pessimistic write lock, with version update.
PESSIMISTIC_READ
          Pessimistic read lock.
PESSIMISTIC_WRITE
          Pessimistic write lock.
ЧИТАТЬ
          Synonymous with OPTIMISTIC.
ЗАПИСАТЬ
          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
Synonymous with OPTIMISTIC. OPTIMISTIC is to be preferred for new applications.


WRITE

public static final LockModeType WRITE
Synonymous with OPTIMISTIC_FORCE_INCREMENT. OPTIMISTIC_FORCE_IMCREMENT is to be preferred for new applications.


OPTIMISTIC

public static final LockModeType OPTIMISTIC
Optimistic lock.

Since:
Java Persistence 2.0

OPTIMISTIC_FORCE_INCREMENT

public static final LockModeType OPTIMISTIC_FORCE_INCREMENT
Optimistic lock, with version update.

Since:
Java Persistence 2.0

PESSIMISTIC_READ

public static final LockModeType PESSIMISTIC_READ
Pessimistic read lock.

Since:
Java Persistence 2.0

PESSIMISTIC_WRITE

public static final LockModeType PESSIMISTIC_WRITE
Pessimistic write lock.

Since:
Java Persistence 2.0

PESSIMISTIC_FORCE_INCREMENT

public static final LockModeType PESSIMISTIC_FORCE_INCREMENT
Pessimistic write lock, with version update.

Since:
Java Persistence 2.0

NONE

public static final LockModeType NONE
No lock.

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:
IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null


Представьте ошибку или функцию

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41

free hit counter