Package org.hibernate

Class LockOptions

java.lang.Object
org.hibernate.LockOptions
All Implemented Interfaces:
Serializable

@Deprecated(since="7", forRemoval=true) public class LockOptions extends Object implements Serializable
Deprecated, for removal: This API element is subject to removal in a future version.
Since JPA 3.2 and Hibernate 7, a LockMode, Timeout, or PessimisticLockScope may be passed directly as an option to find(), refresh(), or lock(). Therefore, this class is obsolete as an API and will be moved to an SPI package.

For HQL/JPQL queries, locking should be controlled via operations of the SelectionQuery interface:

The interface Timeouts provides several operations to simplify migration.
Contains a set of options describing how a row of a database table mapped by an entity should be locked. For Session.lock(Object, LockOptions), Session.get(Class, Object, LockOptions), or Session.refresh(Object, LockOptions), the relevant options are:

Timeout and lock scope are ignored if the specified LockMode represents a flavor of optimistic locking.

In HQL and criteria queries, lock modes can be defined in an even more granular fashion, with the option to specify a lock mode that applies only to a certain query alias.

Finally, the use of follow-on locking may be force enabled or disabled, overriding the default behavior of the SQL dialect by passing a non-null argument to setFollowOnLocking(Boolean).

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
    static final LockOptions
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
    static final LockOptions
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
    static final LockOptions
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
    static final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    This, and the other constants on this class, will be removed.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Construct an instance with mode LockMode.NONE and no timeout.
    protected
    LockOptions(boolean immutable, LockMode lockMode)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Internal operation used to create immutable global instances.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Construct an instance with the given mode and no timeout.
     
    LockOptions(LockMode lockMode, int timeout)
    Deprecated.
     
    LockOptions(LockMode lockMode, int timeout, PessimisticLockScope scope)
     
    LockOptions(LockMode lockMode, int timeout, Locking.Scope scope, Locking.FollowOn followOnStrategy)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
     
    LockOptions(LockMode lockMode, Timeout timeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Construct an instance with the given mode and timeout.
     
    LockOptions(LockMode lockMode, Timeout timeout, PessimisticLockScope jpaScope)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Construct an instance with the given mode, timeout, and scope.
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(LockOptions source, LockOptions destination)
    Deprecated, for removal: This API element is subject to removal in a future version.
    LockOptions will be made into a record.
    boolean
    equals(Object object)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    Deprecated.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Whether follow-on locking is allowed or, if not, how to handle cases where Hibernate determines it would need to use follow-on locking.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Retrieve the overall lock mode in effect for this set of options.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use getScope() instead
    Deprecated, for removal: This API element is subject to removal in a future version.
    Associated lock scope
    Deprecated, for removal: This API element is subject to removal in a future version.
    The timeout associated with this options, defining a maximum amount of time that the database should wait to obtain a pessimistic lock before returning an error to the client.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    The timeout, in milliseconds, associated with this options.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Whether this LockOptions instance is "empty".
    Deprecated, for removal: This API element is subject to removal in a future version.
    LockOptions will be made into a record.
    Deprecated, for removal: This API element is subject to removal in a future version.
    LockOptions will be made into a record.
    void
    overlay(LockOptions lockOptions)
    Deprecated, for removal: This API element is subject to removal in a future version.
    LockOptions will be made into a record.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Alias-specific locks are no longer supported, roughly replaced with locking scope.
    setFollowOnLocking(Boolean followOnLocking)
    Deprecated, for removal: This API element is subject to removal in a future version.
    How to handle cases where Hibernate has determined it would need to use follow-on locking.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the overall lock mode.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the associated lock scope
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the timeout associated with this options.
    setTimeOut(int timeout)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the timeout, in milliseconds, associated with this options.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait