}
// maybe we should throw this exception from the start, to save time
}
Object valueToIterate = mapping.getRealAttributeValueFromObject(object, session);
UnitOfWorkImpl uow = isObjectUnregistered ? (UnitOfWorkImpl)session : null;
// First check that object in fact is unregistered.
// toDo: ?? Why is this commented out? Why are we supporting the unregistered thing at all?
// Does not seem to be any public API for this, nor every used internally?
//if (isObjectUnregistered) {
// isObjectUnregistered = !uow.getCloneMapping().containsKey(object);
//}
if (mapping.isCollectionMapping() && (valueToIterate != null)) {
// For bug 2766379 must use the correct version of vectorFor to
// unwrap the result same time.
valueToIterate = mapping.getContainerPolicy().vectorFor(valueToIterate, session);
// toDo: If the value is empty, need to support correct inner/outer join filtering symantics.
// For CR 2612601, try to partially replace the result with already
// registered objects.
if (isObjectUnregistered && (uow.getCloneMapping().get(object) == null)) {
Vector objectValues = (Vector)valueToIterate;
for (int i = 0; i < objectValues.size(); i++) {
Object original = objectValues.elementAt(i);
Object clone = uow.getIdentityMapAccessorInstance().getIdentityMapManager().getFromIdentityMap(original);
if (clone != null) {
objectValues.setElementAt(clone, i);
}
}
}
// For CR 2612601, conforming without registering, a query could be
// bob.get("address").get("city").equal("Ottawa"); where the address
// has been registered and modified in the UOW, but bob has not. Thus
// even though bob does not point to the modified address now, it will
// as soon as it is registered, so should point to it here.
} else if (isObjectUnregistered && (uow.getCloneMapping().get(object) == null)) {
Object clone = uow.getIdentityMapAccessorInstance().getIdentityMapManager().getFromIdentityMap(valueToIterate);
if (clone != null) {
valueToIterate = clone;
}
}
return valueToIterate;