hasNext = resultSet.next();
}
} else {
boolean shouldKeepRow = this.descriptor.getObjectBuilder().shouldKeepRow();
while (hasNext) {
ResultSetRecord row = new ResultSetRecord(fields, fieldsArray, resultSet, metaData, dbAccessor, executionSession, platform, optimizeData);
Object clone = buildObject(row);
if (quickAdd) {
((Collection)clones).add(clone);
} else {
// TODO: investigate is it possible to support MappedKeyMapPolicy - this policy currently is not compatible with ResultSet optimization
cp.addInto(clone, clones, unitOfWork);
}
if (shouldKeepRow) {
if (row.hasResultSet()) {
// ResultSet has not been fully triggered - that means the cached object was used.
// Yet the row still may be cached in a value holder (see loadBatchReadAttributes and loadJoinedAttributes methods).
// Remove ResultSet to avoid attempt to trigger it (already closed) when pk or fk values (already extracted) accessed when the value holder is instantiated.
row.removeResultSet();
} else {
row.removeNonIndirectionValues();
}
}
hasNext = resultSet.next();
}
}