for(int nodeInd = 0; nodeInd < onFindCMRNodes.size(); ++nodeInd)
{
LeftJoinCMRNode node = (LeftJoinCMRNode) onFindCMRNodes.get(nodeInd);
JDBCCMRFieldBridge cmrField = node.cmrField;
ReadAheadCache myCache = cmrField.getJDBCStoreManager().getReadAheadCache();
JDBCEntityBridge relatedEntity = cmrField.getRelatedJDBCEntity();
ReadAheadCache relatedCache = cmrField.getRelatedManager().getReadAheadCache();
// load related id
ref[0] = null;
index = relatedEntity.loadPrimaryKeyResults(rs, index, ref);
Object relatedId = ref[0];
boolean cacheRelatedData = relatedId != null;
if(pk != null)
{
if(cmrField.getMetaData().getRelatedRole().isMultiplicityOne())
{
// cacheRelatedData the value
myCache.addPreloadData(pk,
cmrField,
relatedId == null ? Collections.EMPTY_LIST : Collections.singletonList(relatedId));
}
else
{
Collection cachedValue = myCache.getCachedCMRValue(pk, cmrField);
if(cachedValue == null)
{
cachedValue = new ArrayList();
myCache.addPreloadData(pk, cmrField, cachedValue);
}
if(relatedId != null)
{
if(cachedValue.contains(relatedId))
{
cacheRelatedData = false;
}
else
{
cachedValue.add(relatedId);
}
}
}
}
// load eager load group
if(node.eagerLoadMask != null)
{
JDBCFieldBridge[] tableFields = relatedEntity.getTableFields();
for(int fieldInd = 0; fieldInd < tableFields.length; ++fieldInd)
{
if(node.eagerLoadMask[fieldInd])
{
JDBCFieldBridge field = tableFields[fieldInd];
ref[0] = null;
index = field.loadArgumentResults(rs, index, ref);
if(cacheRelatedData)
{
if(log.isTraceEnabled())
{
log.trace("Caching " +
relatedEntity.getEntityName() +
'[' +
relatedId +
"]." +
field.getFieldName() + "=" + ref[0]);
}