程序包 org.hibernate
类 LockOptions
- java.lang.Object
-
- org.hibernate.LockOptions
-
- 所有已实现的接口:
Serializable
public class LockOptions extends Object implements Serializable
Contains locking details (LockMode, Timeout and Scope).- 作者:
- Scott Marlow
- 另请参阅:
- 序列化表格
-
-
字段概要
字段 修饰符和类型 字段 说明 static intNO_WAITIndicates that the database should not wait at all to acquire the pessimistic lock.static LockOptionsNONERepresents LockMode.NONE (timeout + scope do not apply).static LockOptionsREADRepresents LockMode.READ (timeout + scope do not apply).static intSKIP_LOCKEDIndicates that rows that are already locked should be skipped.static LockOptionsUPGRADERepresents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).static intWAIT_FOREVERIndicates that there is no timeout for the acquisition.
-
构造器概要
构造器 构造器 说明 LockOptions()Constructs a LockOptions with all default options.LockOptions(LockMode lockMode)Constructs a LockOptions with the given lock mode.
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static LockOptionscopy(LockOptions source, LockOptions destination)Perform a shallow copy.LockModefindGreatestLockMode()Currently needed for follow-on locking.intgetAliasLockCount()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.LockModegetAliasSpecificLockMode(String alias)Get theLockModeexplicitly specified for the given alias viasetAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)Iterable<Map.Entry<String,LockMode>>getAliasSpecificLocks()Iterable access to alias (key) and LockMode (value) as Map.Entry.LockModegetEffectiveLockMode(String alias)Determine theLockModeto apply to the given alias.BooleangetFollowOnLocking()Retrieve the current follow-on-locking setting.LockModegetLockMode()Retrieve the overall lock mode in effect for this set of options.booleangetScope()Retrieve the current lock scope setting.intgetTimeOut()Retrieve the current timeout setting.booleanhasAliasSpecificLockModes()Does this LockOptions object define alias-specific lock modes?LockOptionsmakeCopy()Make a copy.LockOptionssetAliasSpecificLockMode(String alias, LockMode lockMode)Specify theLockModeto be used for a specific query alias.LockOptionssetFollowOnLocking(Boolean followOnLocking)Set the the follow-on-locking setting.LockOptionssetLockMode(LockMode lockMode)Set the overallLockModeto be used.LockOptionssetScope(boolean scope)Set the scope.LockOptionssetTimeOut(int timeout)Set the timeout setting.
-
-
-
字段详细资料
-
NONE
public static final LockOptions NONE
Represents LockMode.NONE (timeout + scope do not apply).
-
READ
public static final LockOptions READ
Represents LockMode.READ (timeout + scope do not apply).
-
UPGRADE
public static final LockOptions UPGRADE
Represents LockMode.UPGRADE (will wait forever for lock and scope of false meaning only entity is locked).
-
NO_WAIT
public static final int NO_WAIT
Indicates that the database should not wait at all to acquire the pessimistic lock.- 另请参阅:
getTimeOut(), 常量字段值
-
WAIT_FOREVER
public static final int WAIT_FOREVER
Indicates that there is no timeout for the acquisition.- 另请参阅:
getTimeOut(), 常量字段值
-
SKIP_LOCKED
public static final int SKIP_LOCKED
Indicates that rows that are already locked should be skipped.- 另请参阅:
getTimeOut(), 常量字段值
-
-
构造器详细资料
-
LockOptions
public LockOptions()
Constructs a LockOptions with all default options.
-
LockOptions
public LockOptions(LockMode lockMode)
Constructs a LockOptions with the given lock mode.- 参数:
lockMode- The lock mode to use
-
-
方法详细资料
-
getLockMode
public LockMode getLockMode()
Retrieve the overall lock mode in effect for this set of options. In certain contexts (hql and criteria), lock-modes can be defined in an even more granularper-aliasfashion- 返回:
- The overall lock mode.
-
setLockMode
public LockOptions setLockMode(LockMode lockMode)
Set the overallLockModeto be used. The default isLockMode.NONE- 参数:
lockMode- The new overall lock mode to use.- 返回:
- this (for method chaining).
-
setAliasSpecificLockMode
public LockOptions setAliasSpecificLockMode(String alias, LockMode lockMode)
Specify theLockModeto be used for a specific query alias.- 参数:
alias- used to reference the LockMode.lockMode- The lock mode to apply to the given alias- 返回:
- this LockRequest instance for operation chaining.
- 另请参阅:
Query.setLockMode(String, LockMode),Criteria.setLockMode(LockMode),Criteria.setLockMode(String, LockMode)
-
getAliasSpecificLockMode
public LockMode getAliasSpecificLockMode(String alias)
Get theLockModeexplicitly specified for the given alias viasetAliasSpecificLockMode(java.lang.String, org.hibernate.LockMode)Differs fromgetEffectiveLockMode(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.- 返回:
- The explicit lock mode for that alias.
-
getEffectiveLockMode
public LockMode getEffectiveLockMode(String alias)
Determine theLockModeto apply to the given alias. If no mode was explicitlyset, theoverall modeis returned. If the overall lock mode is null as well,LockMode.NONEis returned. Differs fromgetAliasSpecificLockMode(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.- 返回:
- The effective lock mode.
-
hasAliasSpecificLockModes
public boolean hasAliasSpecificLockModes()
Does this LockOptions object define alias-specific lock modes?- 返回:
trueif this LockOptions object define alias-specific lock modes;falseotherwise.
-
getAliasLockCount
public int getAliasLockCount()
Get the number of aliases that have specific lock modes defined.- 返回:
- the number of explicitly defined alias lock modes.
-
getAliasLockIterator
public Iterator<Map.Entry<String,LockMode>> getAliasLockIterator()
Iterator for accessing Alias (key) and LockMode (value) as Map.Entry.- 返回:
- Iterator for accessing the Map.Entry's
-
getAliasSpecificLocks
public Iterable<Map.Entry<String,LockMode>> getAliasSpecificLocks()
Iterable access to alias (key) and LockMode (value) as Map.Entry.- 返回:
- Iterable for accessing the Map.Entry's
-
findGreatestLockMode
public LockMode findGreatestLockMode()
Currently needed for follow-on locking.- 返回:
- The greatest of all requested lock modes.
-
getTimeOut
public int getTimeOut()
Retrieve the current timeout setting. The timeout is the amount of time, in milliseconds, we should instruct the database to wait for any requested pessimistic lock acquisition.NO_WAIT,WAIT_FOREVERorSKIP_LOCKEDrepresent 3 "magic" values.- 返回:
- timeout in milliseconds,
NO_WAIT,WAIT_FOREVERorSKIP_LOCKED
-
setTimeOut
public LockOptions setTimeOut(int timeout)
Set the timeout setting. SeegetTimeOut()for a discussion of meaning.- 参数:
timeout- The new timeout setting.- 返回:
- this (for method chaining).
- 另请参阅:
getTimeOut()
-
getScope
public boolean getScope()
Retrieve the current lock scope setting. "scope" is a JPA defined term. It is basically a cascading of the lock to associations.- 返回:
- true if locking will be extended to owned associations
-
setScope
public LockOptions setScope(boolean scope)
Set the scope.- 参数:
scope- The new scope setting- 返回:
- this (for method chaining).
-
getFollowOnLocking
public Boolean getFollowOnLocking()
Retrieve the current follow-on-locking setting.- 返回:
- true if follow-on-locking is enabled
-
setFollowOnLocking
public LockOptions setFollowOnLocking(Boolean followOnLocking)
Set the the follow-on-locking setting.- 参数:
followOnLocking- The new follow-on-locking setting- 返回:
- this (for method chaining).
-
makeCopy
public LockOptions makeCopy()
Make a copy.- 返回:
- The copy
-
copy
public static LockOptions copy(LockOptions source, LockOptions destination)
Perform a shallow copy.- 参数:
source- Source for the copy (copied from)destination- Destination for the copy (copied to)- 返回:
- destination
-
-