Package org.hibernate.dialect.lock
Class AbstractSelectLockingStrategy
- java.lang.Object
-
- org.hibernate.dialect.lock.AbstractSelectLockingStrategy
-
- All Implemented Interfaces:
LockingStrategy
- Direct Known Subclasses:
PessimisticReadSelectLockingStrategy
,PessimisticWriteSelectLockingStrategy
,SelectLockingStrategy
public abstract class AbstractSelectLockingStrategy extends Object implements LockingStrategy
BaseLockingStrategy
implementation to support implementations based on issuing SQLSELECT
statements. For non-read locks, this is achieved via the dialect's nativeSELECT ... FOR UPDATE
syntax.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSelectLockingStrategy(Lockable lockable, LockMode lockMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected HibernateException
convertException(Object entity, JDBCException ex)
protected String
determineSql(int timeout)
protected String
generateLockString(int lockTimeout)
protected Lockable
getLockable()
protected LockMode
getLockMode()
protected String
getNoWaitSql()
protected String
getSkipLockedSql()
void
lock(Object id, Object version, Object object, int timeout, EventSource session)
Acquire an appropriate type of lock on the underlying data that will endure until the end of the current transaction.
-
-
-
Method Detail
-
getLockable
protected Lockable getLockable()
-
getLockMode
protected LockMode getLockMode()
-
generateLockString
protected String generateLockString(int lockTimeout)
-
lock
public void lock(Object id, Object version, Object object, int timeout, EventSource session) throws StaleObjectStateException, JDBCException
Description copied from interface:LockingStrategy
Acquire an appropriate type of lock on the underlying data that will endure until the end of the current transaction.- Specified by:
lock
in interfaceLockingStrategy
- Parameters:
id
- The id of the row to be lockedversion
- The current version (or null if not versioned)object
- The object logically being locked (currently not used)timeout
- timeout in milliseconds, 0 = no wait, -1 = wait indefinitelysession
- The session from which the lock request originated- Throws:
StaleObjectStateException
- Indicates an inability to locate the database row as part of acquiring the requested lock.JDBCException
-
convertException
protected HibernateException convertException(Object entity, JDBCException ex)
-
determineSql
protected String determineSql(int timeout)
-
getNoWaitSql
protected String getNoWaitSql()
-
getSkipLockedSql
protected String getSkipLockedSql()
-
-