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
NONE represents LockMode.NONE (timeout + scope do not apply)
|
static LockOptions |
READ
READ represents LockMode.READ (timeout + scope do not apply)
|
static LockOptions |
UPGRADE
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() |
LockOptions(LockMode lockMode) |
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 |
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. |
LockMode |
getEffectiveLockMode(String alias)
Determine the
LockMode to apply to the given alias. |
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() |
LockOptions |
makeCopy() |
LockOptions |
setAliasSpecificLockMode(String alias,
LockMode lockMode)
Specify the
LockMode to be used for a specific query alias. |
LockOptions |
setLockMode(LockMode lockMode)
Set the overall
LockMode to be used. |
LockOptions |
setScope(boolean scope)
Set the cope.
|
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 LockOptions()
public LockOptions(LockMode lockMode)
public 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()
public int getAliasLockCount()
public Iterator getAliasLockIterator()
public LockMode findGreatestLockMode()
public int getTimeOut()
NO_WAIT
and WAIT_FOREVER
represent 2 "magic" values.NO_WAIT
or WAIT_FOREVER
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 static LockOptions copy(LockOptions source, LockOptions destination)
source
- Source for the copy (copied from)destination
- Destination for the copy (copied to)public LockOptions makeCopy()
Copyright © 2018 JBoss by Red Hat. All rights reserved.