Package org.apache.openjpa.jdbc.kernel
Class PessimisticLockManager
- java.lang.Object
-
- org.apache.openjpa.kernel.AbstractLockManager
-
- org.apache.openjpa.kernel.VersionLockManager
-
- org.apache.openjpa.jdbc.kernel.PessimisticLockManager
-
- All Implemented Interfaces:
JDBCLockManager,LockLevels,LockManager,Closeable
- Direct Known Subclasses:
MixedLockManager
public class PessimisticLockManager extends VersionLockManager implements JDBCLockManager
Lock manager that uses exclusive database locks.- Author:
- Marc Prud'hommeaux
-
-
Field Summary
Fields Modifier and Type Field Description protected JDBCStore_storestatic intLOCK_DATASTORE_ONLY-
Fields inherited from class org.apache.openjpa.kernel.AbstractLockManager
ctx, log
-
Fields inherited from interface org.apache.openjpa.kernel.LockLevels
LOCK_NONE, LOCK_READ, LOCK_WRITE
-
-
Constructor Summary
Constructors Constructor Description PessimisticLockManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckLock(java.sql.ResultSet rs, OpenJPAStateManager sm, int timeout)This method is to provide override for non-JDBC or JDBC-like implementation of checking lock from the result set.protected java.sql.ResultSetexecuteQuery(java.sql.Connection conn, java.sql.PreparedStatement stmnt, SQLBuffer sql)This method is to provide override for non-JDBC or JDBC-like implementation of executing query.protected java.util.List<SQLBuffer>getLockRows(DBDictionary dict, java.lang.Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory)JDBCStoregetStore()voidloadedForUpdate(OpenJPAStateManager sm)Notification that the given instance was loaded via a result set produced by a FOR UPDATE select.protected voidlockInternal(OpenJPAStateManager sm, int level, int timeout, java.lang.Object sdata, boolean postVersionCheck)Marks the instance's transactional status in accordance with the settings ofVersionLockManager.getVersionCheckOnReadLock()andVersionLockManager.getVersionUpdateOnWriteLock().protected voidlockJoinTables(java.util.List<SQLBuffer> sqls, DBDictionary dict, java.lang.Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory)protected java.sql.PreparedStatementprepareStatement(java.sql.Connection conn, SQLBuffer sql)This method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.booleanselectForUpdate(Select sel, int lockLevel)Return whether to issue the given select FOR UPDATE, depending on the capabilities of the dictionary and the fetch configuration.voidsetContext(StoreContext ctx)Set the context this lock manager is associated with.-
Methods inherited from class org.apache.openjpa.kernel.VersionLockManager
getLockLevel, getVersionCheckOnReadLock, getVersionUpdateOnWriteLock, lock, optimisticLockInternal, refreshLock, release, setLockLevel, setVersionCheckOnReadLock, setVersionUpdateOnWriteLock
-
Methods inherited from class org.apache.openjpa.kernel.AbstractLockManager
beginTransaction, close, endTransaction, getContext, lockAll, skipRelationFieldLock
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.jdbc.kernel.JDBCLockManager
skipRelationFieldLock
-
Methods inherited from interface org.apache.openjpa.kernel.LockManager
beginTransaction, close, endTransaction, getLockLevel, lock, lockAll, refreshLock, release
-
-
-
-
Field Detail
-
LOCK_DATASTORE_ONLY
public static final int LOCK_DATASTORE_ONLY
- See Also:
- Constant Field Values
-
_store
protected JDBCStore _store
-
-
Method Detail
-
setContext
public void setContext(StoreContext ctx)
Description copied from interface:LockManagerSet the context this lock manager is associated with. This will be invoked in the lock manager before any other methods are called.- Specified by:
setContextin interfaceLockManager- Overrides:
setContextin classAbstractLockManager
-
selectForUpdate
public boolean selectForUpdate(Select sel, int lockLevel)
Description copied from interface:JDBCLockManagerReturn whether to issue the given select FOR UPDATE, depending on the capabilities of the dictionary and the fetch configuration.- Specified by:
selectForUpdatein interfaceJDBCLockManager
-
loadedForUpdate
public void loadedForUpdate(OpenJPAStateManager sm)
Description copied from interface:JDBCLockManagerNotification that the given instance was loaded via a result set produced by a FOR UPDATE select.- Specified by:
loadedForUpdatein interfaceJDBCLockManager
-
lockInternal
protected void lockInternal(OpenJPAStateManager sm, int level, int timeout, java.lang.Object sdata, boolean postVersionCheck)
Description copied from class:VersionLockManagerMarks the instance's transactional status in accordance with the settings ofVersionLockManager.getVersionCheckOnReadLock()andVersionLockManager.getVersionUpdateOnWriteLock(). Override to perform additional locking.- Overrides:
lockInternalin classVersionLockManager- See Also:
StoreContext.transactional(java.lang.Object, boolean, org.apache.openjpa.kernel.OpCallbacks)
-
getLockRows
protected java.util.List<SQLBuffer> getLockRows(DBDictionary dict, java.lang.Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory)
-
lockJoinTables
protected void lockJoinTables(java.util.List<SQLBuffer> sqls, DBDictionary dict, java.lang.Object id, ClassMapping mapping, JDBCFetchConfiguration fetch, SQLFactory factory)
-
getStore
public JDBCStore getStore()
-
prepareStatement
protected java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, SQLBuffer sql) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of preparing statement.- Throws:
java.sql.SQLException
-
executeQuery
protected java.sql.ResultSet executeQuery(java.sql.Connection conn, java.sql.PreparedStatement stmnt, SQLBuffer sql) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of executing query.- Throws:
java.sql.SQLException
-
checkLock
protected void checkLock(java.sql.ResultSet rs, OpenJPAStateManager sm, int timeout) throws java.sql.SQLExceptionThis method is to provide override for non-JDBC or JDBC-like implementation of checking lock from the result set.- Throws:
java.sql.SQLException
-
-