Hello, I found this in the spec:
4.10 Bulk Update and Delete Operations
...
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 transaction in a new persistence con-
text or before fetching or accessing entities whose state
might be affected by such operations.
On 12/04/2014 09:30 AM, Michael Hönnig wrote:
Hi Igor,
When execute update JPQL query and then
update entity, that also updated in
JQPL in one transaction
Looks like a found a bug in EclipseLink:
It's works as specified. Unfortunatly I can't find the
specification which defines this behaviour, but I am 100% sure
I've read it somewhere that NO bulk operation invalidates the
cache.
You can eiter invalidate the caches by yourself or use a system
like Oracle DCN (database-triggered cache-invalidation).
But isn't your problem the entity update after the JPQL udate?
When i tested on other JPA implementations
- Hibernate, OpenJPA, DataNucleos
- all works as expected.
Sure that you even used a 2nd level cache? It's by default
activated in EclipseLink but not in Hibernate. Don't know about
the other. By my opinion 2nd level cache usually causes more
trouble than it's doing good.
Best regards
... Michael
|