Hashtable referenceObjectsByKey = null;
synchronized (query) {
referenceObjectsByKey = getBatchReadObjects(query, session);
if (referenceObjectsByKey == null) {
ReadAllQuery batchQuery = (ReadAllQuery)query;
ComplexQueryResult complexResult = (ComplexQueryResult)session.executeQuery(batchQuery, argumentRow);
// Batch query created in ForeignReferenceMapping.prepareNestedBatchQuery without specifying container policy - uses ListContainerPolicy by default.
List results = (List)complexResult.getResult();
referenceObjectsByKey = new Hashtable();
List rows = (List)complexResult.getData();
int size = results.size();
for (int index = 0; index < size; index++) {
Object eachReferenceObject = results.get(index);
CacheKey eachReferenceKey = new CacheKey(extractSourceKeyFromRow((AbstractRecord)rows.get(index), session));
if (!referenceObjectsByKey.containsKey(eachReferenceKey)) {