diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkImpl.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkImpl.java index 3e03ac850a2..d5f8fb43134 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkImpl.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/sessions/UnitOfWorkImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -1078,6 +1078,9 @@ public Object cloneAndRegisterObject(Object original, CacheKey parentCacheKey, C } } try { + if (isConsideredInvalid(original, parentCacheKey, descriptor) && unitOfWorkCacheKey.getObject() != null) { + original = unitOfWorkCacheKey.getObject(); + } // bug:6167576 Must acquire the lock before cloning. workingClone = builder.instantiateWorkingCopyClone(original, this); // PERF: Cache the primary key if implements PersistenceEntity. diff --git a/jpa/eclipselink.jpa.test/resource/eclipselink-annotation-model/osgi/persistence.xml b/jpa/eclipselink.jpa.test/resource/eclipselink-annotation-model/osgi/persistence.xml index a35ea465a8f..c88cff98351 100644 --- a/jpa/eclipselink.jpa.test/resource/eclipselink-annotation-model/osgi/persistence.xml +++ b/jpa/eclipselink.jpa.test/resource/eclipselink-annotation-model/osgi/persistence.xml @@ -1,6 +1,6 @@