* This method is used when computing the nested queries for joined mappings.
* It recurses computing the nested mapping queries and their join indexes.
*/
protected void computeNestedQueriesForJoinedExpressions(List joinedExpressions, AbstractSession session, ObjectLevelReadQuery readQuery) {
for (int index = 0; index < joinedExpressions.size(); index++) {
ObjectExpression objectExpression = (ObjectExpression)joinedExpressions.get(index);
// Expression may not have been initialized.
objectExpression.getBuilder().setSession(session.getRootSession(null));
if (objectExpression.getBuilder().getQueryClass() == null){
objectExpression.getBuilder().setQueryClass(descriptor.getJavaClass());
}
//get the first expression after the builder that is not an aggregate, and populate the aggregateMapping list if there are aggregates
ObjectExpression baseExpression = getFirstNonAggregateExpressionAfterExpressionBuilder(objectExpression, getJoinedAggregateMappings());
// PERF: Cache local join attribute Expression.
this.addJoinedAttribute(baseExpression);
DatabaseMapping mapping = baseExpression.getMapping();
this.getJoinedAttributeMappings().add(mapping);
// focus on the base expression. Nested queries will handle nested expressions, and only need to be processed once
if (mapping.isForeignReferenceMapping() && !getJoinedMappingQueries_().containsKey(mapping)) {
// A nested query must be built to pass to the descriptor that looks like the real query execution would.