Community
Participate
Working Groups
1. Using ChangedFieldsLockingPolicy 2. Execute an update where a field is set to null from a non-null value UPDATE EMPLOYEE SET GENDER = NULL WHERE ((EMP_ID = 100) AND (GENDER = F)) 3. Execute an update where a field is set to a non null value from a null value The following SQL is executed: UPDATE EMPLOYEE SET GENDER = M WHERE ((EMP_ID = 100) AND (GENDER = NULL)) The following exception is seen: [EL Warning]: UnitOfWork(1801334)--Local Exception Stack: Exception [EclipseLink-5006] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.OptimisticLockException Exception Description: The object [Employee: Jill May] cannot be updated because it has changed or been deleted since it was last read. Class> examples.sessions.threetier.model.Employee Primary Key> 2,860 at org.eclipse.persistence.exceptions.OptimisticLockException.objectChangedSinceLastReadWhenUpdating(OptimisticLockException.java:137) at org.eclipse.persistence.descriptors.FieldsLockingPolicy.validateUpdate(FieldsLockingPolicy.java:455) at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1152) at org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:84) at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:290) at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58) at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:736) at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:643) at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108) at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909) The SQL for 2. should be: UPDATE EMPLOYEE SET GENDER = M WHERE ((EMP_ID = 100) AND (GENDER IS NULL)) The cached update call from 1. is being re-used in 2. and this results in incorrect SQL for the query parameters (null value) supplied.
Created attachment 174186 [details] initial patch for issue
Target is being set to 2.2.0, as the fix would be checked into trunk.
Created attachment 174319 [details] Proposed fix and testcase
Created attachment 174861 [details] Proposed changes to EL foundation
Created attachment 174864 [details] Proposed changes to EL foundation testing
Created attachment 177371 [details] Proposed changes to EL foundation Foundation changes, including support for other mappings (1:1, 1:M, M:M, Aggregate, V1:1)
Created attachment 177372 [details] Proposed changes to EL foundation testing Added a new test model and suite to support combined testing for additional mapping and optimistic locking types
Created attachment 177891 [details] Proposed changes to EL foundation (v5)
Fixed in revision: 8130 Checked in September 2nd, 2010.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink