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 12c597698c9..b27f3017dab 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 @@ -809,7 +809,11 @@ public UnitOfWorkChangeSet calculateChanges(Map registeredObjects, UnitOfWorkCha // these are the objects remaining in the UnitOfWork privateOwnedObjects map if (hasPrivateOwnedObjects()) { Collection values = getPrivateOwnedObjects().values(); - Map visitedObjects = new IdentityHashMap(values.stream().collect(Collectors.summingInt(Set::size))); + int initialSize = 0; + for (Set value: values) { + initialSize += value.size(); + } + Map visitedObjects = new IdentityHashMap(initialSize); for (Set privateOwnedObjects : values) { for (Object objectToRemove : privateOwnedObjects) { performRemovePrivateOwnedObjectFromChangeSet(objectToRemove, visitedObjects);