// nested paths must be single valued.
collectionBase = collectionBase.get(pathExpression.getPath(i));
}
String lastPath = pathExpression.getPath(pathExpression.pathSize() - 1);
// The following code is copied from Expression.noneOf and altered a bit
Expression criteria = newBuilder.equal(parentExpression).and(collectionBase.anyOf(lastPath).equal(entityExpression));
ReportQuery subQuery = new ReportQuery();
subQuery.setShouldRetrieveFirstPrimaryKey(true);
subQuery.setSelectionCriteria(criteria);
// subQuery has the same reference class as parentExpression (which is an ExpressionBuilder).
subQuery.setReferenceClass(((ExpressionBuilder)parentExpression).getQueryClass());