Top Description Fields Constructors Methods
org.hibernate.dialect.lock

public Class PessimisticReadUpdateLockingStrategy

extends Object
implements LockingStrategy
Class Inheritance
All Implemented Interfaces
org.hibernate.dialect.lock.LockingStrategy
Imports
org.hibernate.*, org.hibernate.engine.SessionFactoryImplementor, .SessionImplementor, org.hibernate.exception.JDBCExceptionHelper, org.hibernate.persister.entity.Lockable, org.hibernate.pretty.MessageHelper, org.hibernate.sql.Update, org.slf4j.Logger, .LoggerFactory, java.io.Serializable, java.sql.PreparedStatement, .SQLException

A pessimistic locking strategy where the locks are obtained through update statements.

This strategy is valid for LockMode.PESSIMISTIC_READ This class is a clone of UpdateLockingStrategy.

Authors
Steve Ebersole, Scott Marlow
Since
3.5

Field Summary

Modifier and TypeField and Description
private final Lockable
private final LockMode
private static final Logger
private final String

Constructor Summary

AccessConstructor and Description
public
PessimisticReadUpdateLockingStrategy(Lockable
The metadata for the entity to be locked.
lockable
,
LockMode
Indictates the type of lock to be acquired. Note that read-locks are not valid for this strategy.
lockMode
)

Construct a locking strategy based on SQL UPDATE statements.

Method Summary

Modifier and TypeMethod and Description
protected String
protected LockMode
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
,
SessionImplementor
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 java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lockableback to summary
private final Lockable lockable
lockModeback to summary
private final LockMode lockMode
logback to summary
private static final Logger log
sqlback to summary
private final String sql

Constructor Detail

PessimisticReadUpdateLockingStrategyback to summary
public PessimisticReadUpdateLockingStrategy(Lockable lockable, LockMode lockMode)

Construct a locking strategy based on SQL UPDATE statements.

Parameters
lockable:Lockable

The metadata for the entity to be locked.

lockMode:LockMode

Indictates the type of lock to be acquired. Note that read-locks are not valid for this strategy.

Method Detail

generateLockStringback to summary
protected String generateLockString()
getLockModeback to summary
protected LockMode getLockMode()
lockback to summary
public void lock(Serializable id, Object version, Object object, int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException

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

The session from which the lock request originated

Exceptions
StaleObjectStateException:
Indicates an optimistic lock failure as part of acquiring the requested database lock.
JDBCException:
Indicates errors from the JDBC driver.
See Also
org.hibernate.dialect.lock.LockingStrategy#lock