List objects = response.currentList();
if (!objects.isEmpty()) {
DeepMergeOperation merger = new DeepMergeOperation(context);
// subclass descriptors will be resolved on the fly... here
// find objects base descriptor.
ListIterator it = objects.listIterator();
while (it.hasNext()) {
Persistent object = (Persistent) it.next();
ObjectId id = object.getObjectId();
// sanity check
if (id == null) {
throw new CayenneRuntimeException(
"Server returned an object without an id: "
+ object);
}
// have to resolve descriptor here for every object, as
// often a query will not have any info indicating the
// entity type
ClassDescriptor descriptor = resolver
.getClassDescriptor(id.getEntityName());
it.set(merger.merge(object, descriptor));
}
}
}
}
}