A Persistence application locks entity x with a LockModeType.PESSIMISTIC_READ lock type. Which statement is true?
A Persistence application locks entity x with a LockModeType.PESSIMISTIC_READ lock type. Which statement is true?
When an entity is locked with a LockModeType.PESSIMISTIC_READ lock type, it means that the lock prevents other transactions from acquiring a PESSIMISTIC_WRITE lock on the same entity but doesn't prevent them from reading it. If the lock cannot be obtained because another transaction already holds a lock on the entity, a TransactionRolledbackException is usually thrown to indicate that the transaction has been rolled back due to the lock conflict.
D is the correct answer
The answer should be D.
Answer D. LockModeType.READ Synonymous with OPTIMISTIC. PESSIMISTIC_READ - locks the record with read lock state when you read the record. This prevents other transactions from changing the record, but still allows them to read it. PESSIMISTIC_WRITE - locks the record, preventing other transaction from reading and writing it.