Top Description Methods
org.hibernate.dialect.lock

public Interface LockingStrategy

Known Direct Implementers
org.hibernate.dialect.lock.OptimisticForceIncrementLockingStrategy, org.hibernate.dialect.lock.OptimisticLockingStrategy, org.hibernate.dialect.lock.PessimisticForceIncrementLockingStrategy, org.hibernate.dialect.lock.PessimisticReadUpdateLockingStrategy, org.hibernate.dialect.lock.PessimisticWriteUpdateLockingStrategy, org.hibernate.dialect.lock.UpdateLockingStrategy, org.hibernate.dialect.lock.AbstractSelectLockingStrategy
Imports
java.io.Serializable, org.hibernate.StaleObjectStateException, org.hibernate.engine.spi.SharedSessionContractImplementor

A strategy abstraction for how locks are obtained in the underlying database.

All locking provided implementations assume the underlying database supports (and that the connection is in) at least read-committed transaction isolation. The most glaring exclusion to this is HSQLDB which only offers support for READ_UNCOMMITTED isolation.

Author
Steve Ebersole
Since
3.2
See Also
org.hibernate.dialect.Dialect#getLockingStrategy

Method Summary

Modifier and TypeMethod and Description
public void
lock(Serializable
The id of the row to be locked
id
,
Object
The current version (or null if not versioned)
version
,
Object
The object logically being locked (currently not used)
object
,
int
timeout in milliseconds, 0 = no wait, -1 = wait indefinitely
timeout
,
SharedSessionContractImplementor
The session from which the lock request originated
session
)

Acquire an appropriate type of lock on the underlying data that will endure until the end of the current transaction.

Method Detail

lockback to summary
public void lock(Serializable id, Object version, Object object, int timeout, SharedSessionContractImplementor session) throws StaleObjectStateException, LockingStrategyException

Acquire an appropriate type of lock on the underlying data that will endure until the end of the current transaction.

Parameters
id:Serializable

The id of the row to be locked

version:Object

The current version (or null if not versioned)

object:Object

The object logically being locked (currently not used)

timeout:int

timeout in milliseconds, 0 = no wait, -1 = wait indefinitely

session:SharedSessionContractImplementor

The session from which the lock request originated

Exceptions
StaleObjectStateException:
Indicates an inability to locate the database row as part of acquiring the requested lock.
LockingStrategyException:
Indicates a failure in the lock attempt