public static interface Session.LockRequest
Contains locking details (LockMode, Timeout and Scope).
Modifier and Type | Field and 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).
|
Modifier and Type | Method and Description |
---|---|
LockMode |
getLockMode()
Get the lock mode.
|
boolean |
getScope()
Check if locking is cascaded to owned collections and relationships.
|
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 the LockMode to be used.
|
Session.LockRequest |
setScope(boolean scope)
Specify if LockMode should be cascaded to owned collections and relationships.
|
Session.LockRequest |
setTimeOut(int timeout)
Specify the pessimistic lock timeout (check if your dialect supports this option).
|
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.
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).
LockMode getLockMode()
Get the lock mode.
Session.LockRequest setLockMode(LockMode lockMode)
Specify the LockMode to be used. The default is LockMode.none.
lockMode
- The lock mode to use for this requestint getTimeOut()
Get the timeout setting.
Session.LockRequest setTimeOut(int timeout)
Specify the pessimistic lock timeout (check if your dialect supports this option). The default pessimistic lock behavior is to wait forever for the lock.
timeout
- is time in milliseconds to wait for lock. -1 means wait forever and 0 means no wait.boolean getScope()
Check if locking is cascaded to owned collections and relationships.
Session.LockRequest setScope(boolean scope)
Specify if LockMode should be cascaded to owned collections and relationships.
The association must be mapped with cascade="lock"
for scope=true to work.
scope
- true
to cascade locks; false
to not.this
, for method chainingvoid lock(String entityName, Object object)
Perform the requested locking.
entityName
- The name of the entity to lockobject
- The instance of the entity to lockvoid lock(Object object)
Perform the requested locking.
object
- The instance of the entity to lockCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.