Optimistic Lock Exception With Invalid Entity From Second-Level (L2) Cache
(Doc ID 3047463.1)
Last updated on SEPTEMBER 18, 2024
Applies to:
Oracle TopLink - Version 14.1.1 and laterInformation in this document applies to any platform.
Symptoms
Using EclipseLink 2.7.15v20240516 version, a Java Persistence API (JPA) application was created. While running the application, OptimisticLockException is incorrectly thrown under the following environmental conditions:
i. JPA L2 cache enabled
ii. Weaving is applied to used entities
iii. @Version annotation is used
ERROR
-----------------------
[EL Warning]: UnitOfWork(2017530134)--Local Exception Stack:
Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.7.15.v20240516): org.eclipse.persistence.exceptions.OptimisticLockException
Exception Description: The object [com.example.entity.TransportNode ] cannot be updated because it has changed or been deleted since it was last read.
Class> com.example.entity.TransportNode Primary Key> NODE_01
at org.eclipse.persistence.exceptions.OptimisticLockException.objectChangedSinceLastReadWhenUpdating(OptimisticLockException.java:146)
at org.eclipse.persistence.descriptors.VersionLockingPolicy.validateUpdate(VersionLockingPolicy.java:792)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1170)
at org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:86)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:327)
at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:60)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:913)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:812)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:110
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Cause |
Solution |
References |