Persistence application locks entity x with a LockModeType. PESSIMISTIC_READ lock type, which statement is true?
A.
This operation will force serialization among transactions attempting to read the entity data.
B.
This operation will result in a TransactionRolledbackException if the lock cannot be obtained.
C.
If the application later updates the entity, and the changes are flushed to the database, the lock will be converted to an exclusive lock.
D.
LockModeType. PESSIMISTIC_READ is the synonym of the LockModeType.READ.
C
C is right.
“C”
Correct answer is C.
According to the JPA 2.0 Specification (3.4.4.2 PESSIMISTIC_READ, PESSIMISTIC_WRITE,
PESSIMISTIC_FORCE_INCREMENT):
A lock with LockModeType.PESSIMISTIC_WRITE can be obtained on an entity instance to force serialization among transactions attempting to update the entity data. A lock with LockModeType.PESSIMISTIC_READ can be used to query data using repeatable-read semantics without the need to reread the data at the end of the transaction to obtain a lock, and
without blocking other transactions reading the data. A lock with LockMode-Type.PESSIMISTIC_WRITE can be used when querying data and there is a high likelihood
of deadlock or update failure among concurrent updating transactions.
When an application locks an entity with LockModeType.PESSIMISTIC_READ and later updates
that entity, the lock must be converted to an exclusive lock when the entity is flushed to the database.
I’m a guy. The focus is both myself and other men. Clearly many of these apply to women as well, but there are different roles for men and women. We are different.
copy vintage bvlgari rings