3.10.3.4. Lock Manager
OpenJPA delegates the actual work of locking objects to the system’s
org.apache.openjpa.kernel.LockManager.
This plugin is controlled by the openjpa.LockManager configuration property.
You can write your own lock manager, or use one of the bundled options:
-
mixed: This is an alias for the org.apache.openjpa.jdbc.kernel.MixedLockManager , which implements the JPA 2.0 specification entity locking behaviors. It combines both the optimistic and pessimistic semantics controlled by lock mode argument in methods define in the EntityManager and Query interfaces or OpenJPA lock level properties.
The mixed LockManager inherits all the properties available from version and pessimistic LockManagers.
For example: VersionCheckOnReadLock and VersionUpdateOnWriteLock properties.
This is the default openjpa.LockManager setting in OpenJPA.
* pessimistic: This is an alias for the org.apache.openjpa.jdbc.kernel.PessimisticLockManager , which uses SELECT FOR UPDATE statements (or the database’s equivalent) to lock the database rows corresponding to locked objects. This lock manager does not distinguish between read locks and write locks; all locks are write locks.
The pessimistic LockManager can be configured to additionally perform the version checking and incrementing behavior of the version lock manager described below by setting its
VersionCheckOnReadLock and VersionUpdateOnWriteLock properties:
<property name="openjpa.LockManager" value="pessimistic(VersionCheckOnReadLock=true,VersionUpdateOnWriteLock=true)"/>
-
version: This is an alias for the org.apache.openjpa.kernel.VersionLockManager. This lock manager does not perform any exclusive locking, but instead ensures read consistency by verifying that the version of all read-locked instances is unchanged at the end of the transaction. Furthermore, a write lock will force an increment to the version at the end of the transaction, even if the object is not otherwise modified. This ensures read consistency with non-blocking behavior. -
none: This is an alias for the org.apache.openjpa.kernel.NoneLockManager, which does not perform any locking at all.
|
|
In order for the |
<property name="openjpa.LockManager" value="none"/>