public static interface

Session.LockRequest

org.hibernate.Session.LockRequest

Class Overview

Contains locking details (LockMode, Timeout and Scope).

Summary

Constants
int PESSIMISTIC_NO_WAIT
int PESSIMISTIC_WAIT_FOREVER
Public Methods
abstract LockMode getLockMode()
Get the lock mode.
abstract boolean getScope()
Check if locking is cascaded to owned collections and relationships.
abstract int getTimeOut()
Get the timeout setting.
abstract void lock(Object object)
abstract void lock(String entityName, Object object)
abstract Session.LockRequest setLockMode(LockMode lockMode)
Specify the LockMode to be used.
abstract Session.LockRequest setScope(boolean scope)
Specify if LockMode should be cascaded to owned collections and relationships.
abstract Session.LockRequest setTimeOut(int timeout)
Specify the pessimistic lock timeout (check if your dialect supports this option).

Constants

public static final int PESSIMISTIC_NO_WAIT

Constant Value: 0 (0x00000000)

public static final int PESSIMISTIC_WAIT_FOREVER

Constant Value: -1 (0xffffffff)

Public Methods

public abstract LockMode getLockMode ()

Get the lock mode.

Returns
  • the lock mode.

public abstract boolean getScope ()

Check if locking is cascaded to owned collections and relationships.

Returns
  • true if locking will be extended to owned collections and relationships.

public abstract int getTimeOut ()

Get the timeout setting.

Returns
  • timeout in milliseconds, -1 for indefinite wait and 0 for no wait.

public abstract void lock (Object object)

public abstract void lock (String entityName, Object object)

public abstract Session.LockRequest setLockMode (LockMode lockMode)

Specify the LockMode to be used. The default is LockMode.none.

Returns
  • this LockRequest instance for operation chaining.

public abstract 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.

public abstract 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.

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.