Home » Oracle » 1z0-898 » WhichEntityManager API will lock entity with a pessimistic lock?
WhichEntityManager API will lock entity with a pessimistic lock?
A. em.lock(x,LockModeType.WRITE)
B. em.lock(x,LockModeType.PESSIMISTIC)
C. em.lock(x,LockModeType.PESSIMISTIC_READ)
D. em.lock(x,LockModeType.OPTIMISTIC_FORCE_INCREMENT)
Correct Answer: C
Explanation/Reference:
Explanation:
Setting a Pessimistic Lock
An entity object can be locked explicitly by the lock method:
em.lock(employee, LockModeType.PESSIMISTIC_WRITE);
The first argument is an entity object. The second argument is the requested lock mode.
A LockTimeoutException is thrown if the requested pessimistic lock cannot be granted:
*A PESSIMISTIC_READ lock request fails if another user (which is represented by another EntityManager instance) currently holds a PESSIMISTIC_WRITE lock on that database object.
*A PESSIMISTIC_WRITE lock request fails if another user currently holds either a PESSIMISTIC_WRITE lock or a PESSIMISTIC_READ lock on that database object.
References:
Download Printable PDF. VALID exam to help you PASS.
|
|