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).
| Modifier and Type | Field and Description |
|---|---|
| private Map | |
| private Boolean | |
| private final boolean | |
| private LockMode | |
| public static final int | NO_WAIT
Indicates that the database should not wait at all to acquire a pessimistic lock which is not immediately available. |
| public static final LockOptions | NONE
Represents |
| pack-priv static final LockOptions | OPTIMISTIC
Represents |
| pack-priv static final LockOptions | OPTIMISTIC_FORCE_INCREMENT
Represents |
| pack-priv static final LockOptions | |
| pack-priv static final LockOptions | PESSIMISTIC_READ
Represents |
| pack-priv static final LockOptions | PESSIMISTIC_WRITE
Represents |
| public static final LockOptions | READ
Represents |
| private boolean | |
| public static final int | SKIP_LOCKED
Indicates that rows which are already locked should be skipped. |
| private int | |
| public static final LockOptions | UPGRADE
Represents |
| pack-priv static final LockOptions | UPGRADE_NOWAIT
Represents |
| pack-priv static final LockOptions | UPGRADE_SKIPLOCKED
Represents |
| public static final int | WAIT_FOREVER
Indicates that there is no timeout for the lock acquisition, that is, that the database should in principle wait forever to obtain the lock. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | LockOptions(LockMode
The initial lock mode lockMode)Construct an instance with the given mode
and |
| public | LockOptions(LockMode
The initial lock mode lockMode, int The initial timeout timeout)Construct an instance with the given mode and timeout. |
| public | LockOptions(LockMode
The initial lock mode lockMode, int The initial timeout timeout, PessimisticLockScope The initial lock scope scope)Construct an instance with the given mode,
timeout, and |
| private | LockOptions(boolean immutable, LockMode lockMode)
Internal operation used to create immutable global instances. |
| Modifier and Type | Method and Description |
|---|---|
| public static LockOptions | Returns: destinationSource for the copy (copied from) source, LockOptions Destination for the copy (copied to) destination)Copy the options in the first given instance of
|
| public boolean | equals(Object
the reference object with which to compare. object)Overrides java. |
| public LockMode | Returns: The greatest of all requested lock modes.Currently needed for follow-on locking. |
| public int | Returns: the number of explicitly defined alias lock modes.The number of aliases that have alias-specific lock modes specified. |
| public Iterator | Returns: an iterator over theMap.s
Deprecated
use
Iterator over getAliasSpecificLocks()
Map.s, each containing an alias and its
LockMode.
|
| public LockMode | Returns: The explicit lock mode for that alias.The alias for which to locate the explicit lock mode. alias)Get the |
| public Set | Returns: an iterable with theMap.sSet of |
| public LockMode | Returns: The effective lock mode.The alias for which to locate the effective lock mode. alias)Determine the |
| public Boolean | Returns: true if follow-on locking was force enabled,
false if follow-on locking was force disabled,
or null if the default behavior of the dialect
has not been overridden.Returns a value indicating if follow-on locking was force enabled or disabled, overriding the default behavior of the SQL dialect. |
| public LockMode | Returns: the overall lock modeRetrieve the overall lock mode in effect for this set of options. |
| public PessimisticLockScope | Returns: the currentPessimisticLockScopeThe current lock scope:
|
| public boolean | Returns: true if the lock extends to owned associations
Deprecated
since 6.2. use
The current lock scope setting:
getLockScope()
|
| public int | getTimeOut()
The current timeout, a maximum amount of time in milliseconds that the database should wait to obtain a pessimistic lock before returning an error to the client. |
| public boolean | Returns: true if this object defines alias-specific lock modes;
false otherwise.Does this |
| public int | |
| public boolean | |
| public LockOptions | |
| public LockOptions | Returns: The copy, or this if it was immutable.Make a copy, unless this is an immutable instance. |
| public void | overlay(LockOptions lockOptions)
Copy the given lock options into this instance, merging the alias-specific lock modes. |
| public LockOptions | Returns: this for method chainingthe query alias to which the lock mode applies alias, LockMode the lock mode to apply to the given alias lockMode)Specify the |
| public LockOptions | Returns: this for method chainingThe new follow-on locking setting followOnLocking)Force enable or disable the use of follow-on locking, overriding the default behavior of the SQL dialect. |
| public LockOptions | Returns: this for method chainingthe new overall lock mode lockMode)Set the overall lock mode. |
| public LockOptions | Returns: this for method chainingthe new scope)PessimisticLockScopeSet the lock scope:
|
| public LockOptions | Returns: this for method chainingthe new scope setting scope)
Deprecated
since 6.2. use
Set the lock scope setting:
setLockScope(PessimisticLockScope)
|
| public LockOptions | Returns: this for method chainingthe new timeout setting, in milliseconds timeout)Set the timeout, that is, the maximum amount of time in milliseconds that the database should wait to obtain a pessimistic lock before returning an error to the client. |
| aliasSpecificLockModes | back to summary |
|---|---|
| private Map<String, LockMode> aliasSpecificLockModes | |
| followOnLocking | back to summary |
|---|---|
| private Boolean followOnLocking | |
| immutable | back to summary |
|---|---|
| private final boolean immutable | |
| lockMode | back to summary |
|---|---|
| private LockMode lockMode | |
| NO_WAIT | back to summary |
|---|---|
| public static final int NO_WAIT Indicates that the database should not wait at all to acquire
a pessimistic lock which is not immediately available. This
has the same effect as
| |
| NONE | back to summary |
|---|---|
| public static final LockOptions NONE Represents | |
| OPTIMISTIC | back to summary |
|---|---|
| pack-priv static final LockOptions OPTIMISTIC Represents | |
| OPTIMISTIC_FORCE_INCREMENT | back to summary |
|---|---|
| pack-priv static final LockOptions OPTIMISTIC_FORCE_INCREMENT Represents | |
| PESSIMISTIC_FORCE_INCREMENT | back to summary |
|---|---|
| pack-priv static final LockOptions PESSIMISTIC_FORCE_INCREMENT Represents | |
| PESSIMISTIC_READ | back to summary |
|---|---|
| pack-priv static final LockOptions PESSIMISTIC_READ Represents | |
| PESSIMISTIC_WRITE | back to summary |
|---|---|
| pack-priv static final LockOptions PESSIMISTIC_WRITE Represents | |
| READ | back to summary |
|---|---|
| public static final LockOptions READ Represents | |
| scope | back to summary |
|---|---|
| private boolean scope | |
| SKIP_LOCKED | back to summary |
|---|---|
| public static final int SKIP_LOCKED
Deprecated Indicates that rows which are already locked should be skipped.
| |
| timeout | back to summary |
|---|---|
| private int timeout | |
| UPGRADE | back to summary |
|---|---|
| public static final LockOptions UPGRADE Represents | |
| UPGRADE_NOWAIT | back to summary |
|---|---|
| pack-priv static final LockOptions UPGRADE_NOWAIT Represents | |
| UPGRADE_SKIPLOCKED | back to summary |
|---|---|
| pack-priv static final LockOptions UPGRADE_SKIPLOCKED Represents | |
| WAIT_FOREVER | back to summary |
|---|---|
| public static final int WAIT_FOREVER Indicates that there is no timeout for the lock acquisition, that is, that the database should in principle wait forever to obtain the lock.
| |
| LockOptions | back to summary |
|---|---|
| public LockOptions() Construct an instance with mode | |
| LockOptions | back to summary |
|---|---|
| public LockOptions(LockMode lockMode) Construct an instance with the given mode
and
| |
| LockOptions | back to summary |
|---|---|
| public LockOptions(LockMode lockMode, int timeout) Construct an instance with the given mode and timeout.
| |
| LockOptions | back to summary |
|---|---|
| public LockOptions(LockMode lockMode, int timeout, PessimisticLockScope scope) Construct an instance with the given mode,
timeout, and
| |
| LockOptions | back to summary |
|---|---|
| private LockOptions(boolean immutable, LockMode lockMode) Internal operation used to create immutable global instances. | |
| copy | back to summary |
|---|---|
| public static LockOptions copy(LockOptions source, LockOptions destination) Copy the options in the first given instance of
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| findGreatestLockMode | back to summary |
|---|---|
| public LockMode findGreatestLockMode() Currently needed for follow-on locking.
| |
| getAliasLockCount | back to summary |
|---|---|
| public int getAliasLockCount() The number of aliases that have alias-specific lock modes specified.
| |
| getAliasLockIterator | back to summary |
|---|---|
| public Iterator Deprecated Iterator over | |
| getAliasSpecificLockMode | back to summary |
|---|---|
| public LockMode getAliasSpecificLockMode(String alias) Get the
Differs from | |
| getAliasSpecificLocks | back to summary |
|---|---|
| public Set Set of | |
| getEffectiveLockMode | back to summary |
|---|---|
| public LockMode getEffectiveLockMode(String alias) Determine the
Differs from | |
| getFollowOnLocking | back to summary |
|---|---|
| public Boolean getFollowOnLocking() Returns a value indicating if follow-on locking was force enabled or disabled, overriding the default behavior of the SQL dialect.
| |
| getLockMode | back to summary |
|---|---|
| public LockMode getLockMode() Retrieve the overall lock mode in effect for this set of options.
| |
| getLockScope | back to summary |
|---|---|
| public PessimisticLockScope getLockScope() The current lock scope:
| |
| getScope | back to summary |
|---|---|
| public boolean getScope()
The current lock scope setting:
| |
| getTimeOut | back to summary |
|---|---|
| public int getTimeOut() The current timeout, a maximum amount of time in milliseconds that the database should wait to obtain a pessimistic lock before returning an error to the client.
| |
| hasAliasSpecificLockModes | back to summary |
|---|---|
| public boolean hasAliasSpecificLockModes() Does this
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Determine of the lock options are empty.
| |
| makeCopy | back to summary |
|---|---|
| public LockOptions makeCopy() Make a copy. The new copy will be mutable even if the original wasn't.
| |
| makeDefensiveCopy | back to summary |
|---|---|
| public LockOptions makeDefensiveCopy() Make a copy, unless this is an immutable instance.
| |
| overlay | back to summary |
|---|---|
| public void overlay(LockOptions lockOptions) Copy the given lock options into this instance, merging the alias-specific lock modes. | |
| setAliasSpecificLockMode | back to summary |
|---|---|
| public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode) Specify the
| |
| setFollowOnLocking | back to summary |
|---|---|
| public LockOptions setFollowOnLocking(Boolean followOnLocking) Force enable or disable the use of follow-on locking, overriding the default behavior of the SQL dialect.
| |
| setLockMode | back to summary |
|---|---|
| public LockOptions setLockMode(LockMode lockMode) Set the overall lock mode. The default is
| |
| setLockScope | back to summary |
|---|---|
| public LockOptions setLockScope(PessimisticLockScope scope) Set the lock scope:
| |
| setScope | back to summary |
|---|---|
| public LockOptions setScope(boolean scope)
Set the lock scope setting:
| |
| setTimeOut | back to summary |
|---|---|
| public LockOptions setTimeOut(int timeout) Set the timeout, that is, the maximum amount of time in milliseconds that the database should wait to obtain a pessimistic lock before returning an error to the client.
| |