1Z0-898 · Question #21
An application uses optimistic locking by defining version attributes in its entity classes. The application performs a bulk update of the entities using a JPQL query. Which of the following is…
The correct answer is D. The value of the Version attributes of the updated entitles should be also be explicitly updated by. You must take some precautions with bulk update operations. To paraphrase the JPA specification: bulk updates bypass optimistic locking checks (so you must manually increment the version column and/or manually validate the version column if desired) Note:The object's version…
Question
An application uses optimistic locking by defining version attributes in its entity classes. The application performs a bulk update of the entities using a JPQL query. Which of the following is correct?
Options
- AThe persistence provider will ensure that the version value in each table is updated.
- BThe persistence provider will create a new transaction for the bulk update.
- CAn OptimisticLockException will be thrown by the persistence provider.
- DThe value of the Version attributes of the updated entitles should be also be explicitly updated by
How the community answered
(36 responses)- A6% (2)
- B3% (1)
- C11% (4)
- D81% (29)
Explanation
You must take some precautions with bulk update operations. To paraphrase the JPA specification: bulk updates bypass optimistic locking checks (so you must manually increment the version column and/or manually validate the version column if desired) Note:The object's version attribute is automatically updated by the JPA provider, and should not normally be modified by the application. The one exception is if the application reads the object in one transaction, sends the object to a client, and updates/merges the object in another transaction. In this case the application must ensure that the original object version is used, otherwise any changes in between the read and write will not be detected.
Topics
Community Discussion
No community discussion yet for this question.