An application that uses pessimistic locking calls an updateData method that results in a LockTimeoutException being thrown. What three statements are correct? (Choose three)
A.
The current transaction continues.
B.
The current statement continues.
C.
The current transaction is rolled back.
D.
The current statement is rolled back.
E.
The LockTimeoutException can NOT be caught.
F.
The LockTimeoutException can be caught, and the updateData method retried.
Need review:
http://www.objectdb.com/api/java/jpa/LockTimeoutException
it is correct answer : A D F
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
the PessimisticLockException will be thrown if the database locking failure causes transaction-level rollback
the LockTimeoutException will be thrown if the database locking failure causes only statement-level rollback
In this question, it is given that LockTimeoutException has been thrown. This means the code was not able to obtain the lock but that affected only the current statement. Hence, only the current statement will be rolled back and the transaction will continue.
IF LockTimeoutException will be thrown, the caller can catch it and simply (Pro JPA 2 BOOK)
Hi,
Are those questions still valid or not ?
Thank you
Correct answers are A, D and F.
If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
* the PessimisticLockException will be thrown if the database locking failure causes transaction-level rollback
* the LockTimeoutException will be thrown if the database locking failure causes only statement-level rollback
In this question, it is given that LockTimeoutException has been thrown. This means the code was not able to obtain the lock but that affected only the current statement. Hence, only the current statement will be rolled back and the transaction will continue.