/** * INTERNAL: * This factory method is used to build a subselect that will do a count. * It will count the number of items in baseExpression.anyOf(attribute). */ public static SubSelectExpression createSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, String attribute, Class returnType){ SubSelectExpression expression = new SubSelectExpression(); expression.setBaseExpression(outerQueryBaseExpression); expression.attribute = attribute; expression.criteriaBase = outerQueryCriteria; if (returnType != null){ expression.returnType = returnType; } return expression; } }
/** * INTERNAL: * This factory method is used to build a subselect that will do a count. * It will count the number of items in baseExpression.anyOf(attribute). */ public static SubSelectExpression createSubSelectExpressionForCount(Expression outerQueryBaseExpression, Expression outerQueryCriteria, String attribute, Class returnType){ SubSelectExpression expression = new SubSelectExpression(); expression.setBaseExpression(outerQueryBaseExpression); expression.attribute = attribute; expression.criteriaBase = outerQueryCriteria; if (returnType != null){ expression.returnType = returnType; } return expression; } }
protected void integrateRoot(RootImpl root) { if (this.roots.isEmpty()) { TypeImpl type = ((MetamodelImpl)this.metamodel).getType(this.queryType); 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()); this.queryType = root.getJavaType(); this.currentNode.setBaseExpression(((CommonAbstractCriteriaImpl)this.parent).getBaseExpression()); } super.integrateRoot(root); }
subSelect.setBaseExpression(getBaseExpression().rebuildOn(newBase));
subSelect.setBaseExpression(getBaseExpression().rebuildOn(newBase));
subSelect.setBaseExpression(subSelect.getBaseExpression().twistedForBaseAndContext(newBase, context, oldBase));
subSelect.setBaseExpression(subSelect.getBaseExpression().twistedForBaseAndContext(newBase, context, oldBase));