Hi,
I have a hard time here to understand some points from the persistence spec:
Question #1 - The persistence context is not synchronized with the result of the bulk update or delete.
The persistence context is not synchronized with the result of the bulk update or delete.
Caution should be used when executing bulk update or delete operations because they may result in inconsistencies between the database and the entities in the active persistence context. In general, bulk update and delete operations should only be performed within a separate transaction or at the beginning of a transaction (before entities have been accessed whose state might be affected by such operations.
Based on the above quote, I found one mock exam question and answer:
The result on this code will be returning "normal". The explaination on this is:
Bulk updates are not reflected in the existing persistence context. So it will return "normal".
How someone explain it so I can understand better?
Question #2 - bulk operation bypassing optimistic locking checks.
spec says:
Bulk update maps directly to a database update operation, bypassing optimistic locking checks. Portable applications must manually update the value of the version column, if desired, and/or manually validate the value of the version column.
My question - since I don't have real work experience on
EJB, I am wondering in the real project, anyone had used the bulk operations? It sounds like a common operation to me. But since there would be no optimistic locking checks performed on the bulk operation, I am wondering how do you control the concurrency problem? Just make sure operations should only be performed within a separate transaction or at the beginning of a transaction as stated in the spec???
thanks
Helen Ge