if ((type != null && type.getPersistenceType() == PersistenceType.ENTITY) || queryType.equals(ClassConstants.OBJECT)) {
// this is the first root, set return type and selection and query type
if (this.selection == null) {
this.selection = root;
this.subQuery.getItems().clear();
this.subQuery.addAttribute("", new ConstantExpression(1, root.getCurrentNode().getBuilder()));
this.queryResult = ResultType.ENTITY;
}
}
this.subQuery.setReferenceClass(root.getJavaType());
this.subQuery.setExpressionBuilder(root.getCurrentNode().getBuilder());