objectFromDatabase = readPrivateOwnedForObject(query);
// If the value was changed, both values must be deleted (uow will have inserted the new one).
if ((objectFromDatabase != null) && (objectFromDatabase != objectInMemory)) {
// Also check pk as may not be maintaining identity.
CacheKey cacheKeyForObjectInDatabase = null;
CacheKey cacheKeyForObjectInMemory = new CacheKey(new Vector());
cacheKeyForObjectInDatabase = new CacheKey(getPrimaryKeyForObject(objectFromDatabase, query.getSession()));
if (objectInMemory != null) {
cacheKeyForObjectInMemory = new CacheKey(getPrimaryKeyForObject(objectInMemory, query.getSession()));
}
if (!cacheKeysAreEqual(cacheKeyForObjectInMemory, cacheKeyForObjectInDatabase)) {
if (objectFromDatabase != null) {
DeleteObjectQuery deleteQuery = new DeleteObjectQuery();
deleteQuery.setIsExecutionClone(true);