if (refAnn.lazy() && LazyFeatureDependencies.assertDependencyFullFilled()) {
Object dbVal = mf.getDbObjectValue(dbObject);
if (dbVal != null) {
references = mapr.getProxyFactory().createListProxy(references, referenceObjClass, refAnn.ignoreMissing(),
mapr.getDatastoreProvider());
ProxiedEntityReferenceList referencesAsProxy = (ProxiedEntityReferenceList) references;
if (dbVal instanceof List) {
List<DBRef> refList = (List) dbVal;
Datastore dsi = mapr.getDatastoreProvider().get();
List<Key<Object>> keys = dsi.getKeysByRefs(refList);
if (keys.size() != refList.size()) {
String msg = "Some of the references could not be fetched for " + mf.getFullName() + ". "
+ refList + " != " + keys;
if (!refAnn.ignoreMissing())
throw new MappingException(msg);
else
log.warning(msg);
}
referencesAsProxy.__addAll(keys);
} else {
DBRef dbRef = (DBRef) dbVal;
if (!exists(mf.getSubClass(), dbRef, cache, mapr)) {
String msg = "The reference(" + dbRef.toString() + ") could not be fetched for "
+ mf.getFullName();
if (!refAnn.ignoreMissing())
throw new MappingException(msg);
else
log.warning(msg);
} else {
referencesAsProxy.__add(mapr.refToKey(dbRef));
}
}
}
} else {
Object dbVal = mf.getDbObjectValue(dbObject);