Which of the following is correct?

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?

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?

A.
The persistence provider will ensure that the version value in each table is updated.

B.
The persistence provider will create a new transaction for the bulk update.

C.
An OptimisticLockException will be thrown by the persistence provider.

D.
The value of the Version attributes of the updated entitles should be also be explicitly updated by the query.

Explanation:
http://en.wikibooks.org/wiki/Java_Persistence/Locking(topic: optimistic locking, second paragraph)



Leave a Reply 5

Your email address will not be published. Required fields are marked *


Marian

Marian

D. A is wrong

Ahmed Misbah

Ahmed Misbah

D is correct.

Reference (Pro JPA2 Book):

A couple of words of warning about version fields are in order. The first is that they are not
guaranteed to be updated, either in the managed entities or the database, as part of a bulk update
operation. Some vendors offer support for automatic updating of the version field during bulk updates,
but this cannot be portably relied upon.