Package org.hibernate
Interface Session.LockRequest
-
- Enclosing interface:
- Session
public static interface Session.LockRequest
Contains locking details (LockMode, Timeout and Scope).
-
-
Field Summary
Fields Modifier and Type Field Description static int
PESSIMISTIC_NO_WAIT
Constant usable as a time out value that indicates no wait semantics should be used in attempting to acquire locks.static int
PESSIMISTIC_WAIT_FOREVER
Constant usable as a time out value that indicates that attempting to acquire locks should be allowed to wait forever (apply no timeout).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description LockMode
getLockMode()
Get the lock mode.boolean
getScope()
Check if locking is cascaded to owned collections and associated entities.int
getTimeOut()
Get the timeout setting.void
lock(Object object)
Perform the requested locking.void
lock(String entityName, Object object)
Perform the requested locking.Session.LockRequest
setLockMode(LockMode lockMode)
Specify theLockMode
to be used.Session.LockRequest
setScope(boolean scope)
Specify whether theLockMode
should be cascaded to owned collections and associated entities.Session.LockRequest
setTimeOut(int timeout)
Specify the pessimistic lock timeout.
-
-
-
Field Detail
-
PESSIMISTIC_NO_WAIT
static final int PESSIMISTIC_NO_WAIT
Constant usable as a time out value that indicates no wait semantics should be used in attempting to acquire locks.- See Also:
- Constant Field Values
-
PESSIMISTIC_WAIT_FOREVER
static final int PESSIMISTIC_WAIT_FOREVER
Constant usable as a time out value that indicates that attempting to acquire locks should be allowed to wait forever (apply no timeout).- See Also:
- Constant Field Values
-
-
Method Detail
-
getLockMode
LockMode getLockMode()
Get the lock mode.- Returns:
- the lock mode.
-
setLockMode
Session.LockRequest setLockMode(LockMode lockMode)
Specify theLockMode
to be used. The default isLockMode.NONE
.- Parameters:
lockMode
- the lock mode to use for this request- Returns:
- this
LockRequest
instance for operation chaining.
-
getTimeOut
int getTimeOut()
Get the timeout setting.- Returns:
- timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
-
setTimeOut
Session.LockRequest setTimeOut(int timeout)
Specify the pessimistic lock timeout. The default pessimistic lock behavior is to wait forever for the lock. Lock timeout support is not available in allSQL dialects
.- Parameters:
timeout
- is time in milliseconds to wait for lock. -1 means wait forever and 0 means no wait.- Returns:
- this
LockRequest
instance for operation chaining.
-
getScope
boolean getScope()
Check if locking is cascaded to owned collections and associated entities.- Returns:
- true if locking will be extended to owned collections and associated entities
-
setScope
Session.LockRequest setScope(boolean scope)
Specify whether theLockMode
should be cascaded to owned collections and associated entities. An association must be mapped withCascadeType.LOCK
for this setting to have any effect.- Parameters:
scope
-true
to cascade locks;false
to not.- Returns:
this
, for method chaining
-
lock
void lock(String entityName, Object object)
Perform the requested locking.- Parameters:
entityName
- the name of the entity to lockobject
- the instance of the entity to lock
-
lock
void lock(Object object)
Perform the requested locking.- Parameters:
object
- the instance of the entity to lock
-
-