Top Description Constructors Methods
org.hibernate.dialect.lock

public Class PessimisticWriteSelectLockingStrategy

extends AbstractSelectLockingStrategy
Class Inheritance
Imports
java.sql.PreparedStatement, .ResultSet, .SQLException, org.hibernate.JDBCException, .LockMode, .LockOptions, .StaleObjectStateException, org.hibernate.engine.jdbc.spi.JdbcCoordinator, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.event.spi.EventSource, org.hibernate.persister.entity.Lockable, org.hibernate.pretty.MessageHelper, org.hibernate.sql.SimpleSelect, org.hibernate.stat.spi.StatisticsImplementor

A pessimistic locking strategy where a lock is obtained via a select statement.

For non-read locks, this is achieved through the dialect's native SELECT ... FOR UPDATE syntax.

This strategy is valid for LockMode#PESSIMISTIC_WRITE.

This class is a clone of SelectLockingStrategy.

Authors
Steve Ebersole, Scott Marlow
Since
3.5
See Also
org.hibernate.dialect.Dialect#getForUpdateString(LockMode), org.hibernate.dialect.Dialect#appendLockHint(LockOptions, String)

Constructor Summary

AccessConstructor and Description
public
PessimisticWriteSelectLockingStrategy(Lockable
The metadata for the entity to be locked.
lockable
,
LockMode
Indicates the type of lock to be acquired.
lockMode
)

Deprecated as a consequence of Lockable being deprecated.
Construct a locking strategy based on SQL SELECT statements.

Method Summary

Modifier and TypeMethod and Description
protected String
public void
lock(Object
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
,
EventSource
The session from which the lock request originated
session
)

Implements org.hibernate.dialect.lock.LockingStrategy.lock.

Acquire an appropriate type of lock on the underlying data that will endure until the end of the current transaction.
Inherited from org.hibernate.dialect.lock.AbstractSelectLockingStrategy:
determineSqlgetLockablegetLockModegetNoWaitSqlgetSkipLockedSql

Constructor Detail

PessimisticWriteSelectLockingStrategyback to summary
public PessimisticWriteSelectLockingStrategy(Lockable lockable, LockMode lockMode)

Deprecated

as a consequence of Lockable being deprecated. See corresponding docs for further information.

Construct a locking strategy based on SQL SELECT statements.

Parameters
lockable:Lockable

The metadata for the entity to be locked.

lockMode:LockMode

Indicates the type of lock to be acquired.

Method Detail

generateLockStringback to summary
protected String generateLockString(int lockTimeout)

Implements abstract org.hibernate.dialect.lock.AbstractSelectLockingStrategy.generateLockString.

lockback to summary
public void lock(Object id, Object version, Object object, int timeout, EventSource session)

Implements org.hibernate.dialect.lock.LockingStrategy.lock.

Doc from org.hibernate.dialect.lock.LockingStrategy.lock.

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

Parameters
id:Object

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:EventSource

The session from which the lock request originated

Annotations
@Override