About LockModeType
Locking in JPA
Explains how to use optimistic locking and pessimistic locking in JPA.... lock modes are: PESSIMISTIC_READ LockModeType.PESSIMISTIC_READ enum constant Pessimistic read lock. ... a shared lock. PESSIMISTIC_WRITE LockModeType.PESSIMISTIC_WRITE enum constant Pessimistic write ...
javax.persistence.LockModeType
Lock modes can be specified by means of passing a LockModeType argument to one of the javax.persistence.EntityManager methods that take locks (lock, find, or refresh) or to the Query.setLockMode() or TypedQuery.setLockMode() method.(Enum of JPA)
Setting and Tuning of JPA Queries
Explains various JPA query settings - result range, flush and lock.... See JavaDoc Reference Page... ( LockModeType javax.persistence.LockModeType JPA enum Lock modes can be specified by means of passing a LockModeType argument to one of the javax.persistence.EntityManager methods ...
JPA Miscellaneous
Reference (JavaDoc) of JPA API, including PersistenceUtil, PersistenceUnitUtil, Cache, CacheRetrieveMode, CacheStoreMode, FlushModeType, LockModeType, PessimisticLockScope.... javax.persistence.FlushModeType javax.persistence.LockModeType javax.persistence.PessimisticLockScope ...
values()
Returns an array containing the constants of this enum type.(Static Method of javax.persistence.LockModeType)
lock(entity, lockMode, properties)
Lock an entity instance that is contained in the persistence context with the specified lock mode type and with specified properties.(Method of javax.persistence.EntityManager)
refresh(entity, lockMode, properties)
Refresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type and with specified properties.(Method of javax.persistence.EntityManager)
find(entityClass, primaryKey, lockMode, properties)
Find by primary key and lock, using the specified properties.(Method of javax.persistence.EntityManager)
Pessimistic lock timeout - blocks indefinitely
I've attached a simple test which creates an object then kicks off several threads which each try to update the object. I'm using a pessimistic lock with timeout as follows: ... = em. find ( MyEntity. class , 1 , LockModeType . PESSIMISTIC_WRITE , properties ) ; One ...
valueOf(name)
Returns the enum constant of this type with the specified name.(Static Method of javax.persistence.LockModeType)