Enum Class PessimisticLockScope

java.lang.Object
java.lang.Enum<PessimisticLockScope>
jakarta.persistence.PessimisticLockScope
All Implemented Interfaces:
FindOption, LockOption, RefreshOption, TypedQuery.Option, Serializable, Comparable<PessimisticLockScope>, Constable

public enum PessimisticLockScope extends Enum<PessimisticLockScope> implements FindOption, RefreshOption, LockOption, TypedQuery.Option
Controls how a pessimistic lock applied to an entity affects associated collections and relationships.

A PessimisticLockScope may be passed:

Alternatively, it may be specified via the configuration property jakarta.persistence.lock.scope. This property may be passed as an argument to methods of EntityManager which accept a LockModeType, or to Query.setHint(String, Object), or it may be specified via NamedQuery.hints().

Since:
2.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    The persistence provider must lock the row or rows of: the primary and secondary tables mapped by the entity, including all rows in tables mapped by the entity superclasses of the entity in the case of a joined inheritance hierarchy, join tables mapped by associations owned by the entity, and collection tables mapped by collections belonging to the entity.
    The persistence provider must lock the row or rows of: the primary and secondary tables mapped by the entity, including all rows in tables mapped by the entity superclasses of the entity in the case of a joined inheritance hierarchy, join tables mapped by associations which were fetched as part of the operation which obtained the pessimistic lock, along with the primary and secondary tables mapped by the associated entities, collection tables mapped by collections belonging to the entity which were fetched as part of the operation which obtained the pessimistic lock.
    The persistence provider must lock the row or rows of the primary and secondary tables mapped by the entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • NORMAL

      public static final PessimisticLockScope NORMAL

      The persistence provider must lock the row or rows of the primary and secondary tables mapped by the entity. In the case of a joined inheritance hierarchy, this includes all rows in tables mapped by the entity superclasses of the entity.

      The pessimistic lock does not extend to rows of:

      This is the default behavior of pessimistic locking.

    • EXTENDED

      public static final PessimisticLockScope EXTENDED

      The persistence provider must lock the row or rows of:

      • the primary and secondary tables mapped by the entity, including all rows in tables mapped by the entity superclasses of the entity in the case of a joined inheritance hierarchy,
      • join tables mapped by associations owned by the entity, and
      • collection tables mapped by collections belonging to the entity.

      The pessimistic lock does not extend to rows of:

      • tables mapped by associated entities,
      • join tables mapped by associations not owned by the entity.
    • FETCHED

      public static final PessimisticLockScope FETCHED

      The persistence provider must lock the row or rows of:

      • the primary and secondary tables mapped by the entity, including all rows in tables mapped by the entity superclasses of the entity in the case of a joined inheritance hierarchy,
      • join tables mapped by associations which were fetched as part of the operation which obtained the pessimistic lock, along with the primary and secondary tables mapped by the associated entities,
      • collection tables mapped by collections belonging to the entity which were fetched as part of the operation which obtained the pessimistic lock.

      The pessimistic lock does not extend to data which was not fetched as part of the operation which obtained the pessimistic lock.

      Since:
      4.0
  • Method Details

    • values

      public static PessimisticLockScope[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PessimisticLockScope valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null