public class LockOptions extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static int |
NO_WAIT
Indicates that the database should not wait at all to acquire the pessimistic lock.
|
static LockOptions |
NONE
Represents LockMode.NONE (timeout + scope do not apply).
|
static LockOptions |
READ
Represents LockMode.READ (timeout + scope do not apply).
|
static int |
SKIP_LOCKED
Indicates that rows that are already locked should be skipped.
|
static LockOptions |
UPGRADE
Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).
|
static int |
WAIT_FOREVER
Indicates that there is no timeout for the acquisition.
|
Constructor and Description |
---|
LockOptions()
Constructs a LockOptions with all default options.
|
LockOptions(LockMode lockMode)
Constructs a LockOptions with the given lock mode.
|
Modifier and Type | Method and Description |
---|---|
static LockOptions |
copy(LockOptions source,
LockOptions destination)
Perform a shallow copy.
|
LockMode |
findGreatestLockMode()
Currently needed for follow-on locking.
|
int |
getAliasLockCount()
Get the number of aliases that have specific lock modes defined.
|
Iterator<Map.Entry<String,LockMode>> |
getAliasLockIterator()
Iterator for accessing Alias (key) and LockMode (value) as Map.Entry.
|
LockMode |
getAliasSpecificLockMode(String alias)
Get the
LockMode explicitly specified for the given alias via
setAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)
Differs from getEffectiveLockMode(java.lang.String) in that here we only return
explicitly specified alias-specific lock modes. |
Iterable<Map.Entry<String,LockMode>> |
getAliasSpecificLocks()
Iterable access to alias (key) and LockMode (value) as Map.Entry.
|
LockMode |
getEffectiveLockMode(String alias)
Determine the
LockMode to apply to the given alias. |
Boolean |
getFollowOnLocking()
Retrieve the current follow-on-locking setting.
|
LockMode |
getLockMode()
Retrieve the overall lock mode in effect for this set of options.
|
boolean |
getScope()
Retrieve the current lock scope setting.
|
int |
getTimeOut()
Retrieve the current timeout setting.
|
boolean |
hasAliasSpecificLockModes()
Does this LockOptions object define alias-specific lock modes?
|
LockOptions |
makeCopy()
Make a copy.
|
LockOptions |
setAliasSpecificLockMode(String alias,
LockMode lockMode)
Specify the
LockMode to be used for a specific query alias. |
LockOptions |
setFollowOnLocking(Boolean followOnLocking)
Set the the follow-on-locking setting.
|
LockOptions |
setLockMode(LockMode lockMode)
Set the overall
LockMode to be used. |
LockOptions |
setScope(boolean scope)
Set the scope.
|
LockOptions |
setTimeOut(int timeout)
Set the timeout setting.
|
public static final LockOptions NONE
public static final LockOptions READ
public static final LockOptions UPGRADE
public static final int NO_WAIT
getTimeOut()
,
Constant Field Valuespublic static final int WAIT_FOREVER
getTimeOut()
,
Constant Field Valuespublic static final int SKIP_LOCKED
getTimeOut()
,
Constant Field Valuespublic LockOptions()
public LockOptions(LockMode lockMode)
lockMode
- The lock mode to usepublic LockMode getLockMode()
per-alias
fashionpublic LockOptions setLockMode(LockMode lockMode)
LockMode
to be used. The default is
LockMode.NONE
lockMode
- The new overall lock mode to use.public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode)
LockMode
to be used for a specific query alias.alias
- used to reference the LockMode.lockMode
- The lock mode to apply to the given aliasQuery.setLockMode(String, LockMode)
,
Criteria.setLockMode(LockMode)
,
Criteria.setLockMode(String, LockMode)
public LockMode getAliasSpecificLockMode(String alias)
LockMode
explicitly specified for the given alias via
setAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)
Differs from getEffectiveLockMode(java.lang.String)
in that here we only return
explicitly specified alias-specific lock modes.alias
- The alias for which to locate the explicit lock mode.public LockMode getEffectiveLockMode(String alias)
LockMode
to apply to the given alias. If no
mode was explicitly set
, the
overall mode
is returned. If the overall lock mode is
null as well, LockMode.NONE
is returned.
Differs from getAliasSpecificLockMode(java.lang.String)
in that here we fallback to we only return
the overall lock mode.alias
- The alias for which to locate the effective lock mode.public boolean hasAliasSpecificLockModes()
true
if this LockOptions object define alias-specific lock modes; false
otherwise.public int getAliasLockCount()
public Iterator<Map.Entry<String,LockMode>> getAliasLockIterator()
public Iterable<Map.Entry<String,LockMode>> getAliasSpecificLocks()
public LockMode findGreatestLockMode()
public int getTimeOut()
NO_WAIT
, WAIT_FOREVER
or SKIP_LOCKED
represent 3 "magic" values.NO_WAIT
, WAIT_FOREVER
or SKIP_LOCKED
public LockOptions setTimeOut(int timeout)
getTimeOut()
for a discussion of meaning.timeout
- The new timeout setting.getTimeOut()
public boolean getScope()
public LockOptions setScope(boolean scope)
scope
- The new scope settingpublic Boolean getFollowOnLocking()
public LockOptions setFollowOnLocking(Boolean followOnLocking)
followOnLocking
- The new follow-on-locking settingpublic LockOptions makeCopy()
public static LockOptions copy(LockOptions source, LockOptions destination)
source
- Source for the copy (copied from)destination
- Destination for the copy (copied to)Copyright © 2019 JBoss by Red Hat. All rights reserved.