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); }
++count; this.subQuery.setExpressionBuilder(((InternalSelection)selection.getCompoundSelectionItems().get(0)).getCurrentNode().getBuilder()); } else { TypeImpl type = ((MetamodelImpl)this.metamodel).getType(selection.getJavaType()); this.subQuery.setExpressionBuilder(((InternalSelection)selection).getCurrentNode().getBuilder());
/** * The query must be cloned, and the sub-expression must be cloned using the same outer expression identity. */ protected void postCopyIn(Map alreadyDone) { super.postCopyIn(alreadyDone); ReportQuery clonedQuery = (ReportQuery)getSubQuery().clone(); if (!clonedQuery.isCallQuery()) { if (clonedQuery.getSelectionCriteria() != null) { clonedQuery.setSelectionCriteria(getSubQuery().getSelectionCriteria().copiedVersionFrom(alreadyDone)); // ensure the builder for the subquery is the same as the builder for the subquery's expression // for certain Subqueries (for instance batch queries for direct collections), when we get to this // point the builder for the clonedQuery will already be aliased. Replacing the builder with // the builder for the query's new expression solves this issue. if (clonedQuery.getExpressionBuilder() != null) { clonedQuery.setExpressionBuilder(clonedQuery.getSelectionCriteria().getBuilder()); } } else if (clonedQuery.getExpressionBuilder() != null) { // Must clone the expression builder. clonedQuery.setExpressionBuilder((ExpressionBuilder)clonedQuery.getExpressionBuilder().copiedVersionFrom(alreadyDone)); } // Must also clone report items. clonedQuery.copyReportItems(alreadyDone); } setSubQuery(clonedQuery); }
/** * The query must be cloned, and the sub-expression must be cloned using the same outer expression identity. */ @Override protected void postCopyIn(Map alreadyDone) { initializeCountSubQuery(); super.postCopyIn(alreadyDone); ReportQuery clonedQuery = (ReportQuery)getSubQuery().clone(); if (!clonedQuery.isCallQuery()) { if (clonedQuery.getSelectionCriteria() != null) { clonedQuery.setSelectionCriteria(getSubQuery().getSelectionCriteria().copiedVersionFrom(alreadyDone)); // ensure the builder for the subquery is the same as the builder for the subquery's expression // for certain Subqueries (for instance batch queries for direct collections), when we get to this // point the builder for the clonedQuery will already be aliased. Replacing the builder with // the builder for the query's new expression solves this issue. if (clonedQuery.getExpressionBuilder() != null) { clonedQuery.setExpressionBuilder((ExpressionBuilder)clonedQuery.getExpressionBuilder().copiedVersionFrom(alreadyDone)); } } else if (clonedQuery.getExpressionBuilder() != null) { // Must clone the expression builder. clonedQuery.setExpressionBuilder((ExpressionBuilder)clonedQuery.getExpressionBuilder().copiedVersionFrom(alreadyDone)); } // Must also clone report items, group by, having, order by. clonedQuery.copyReportItems(alreadyDone); } setSubQuery(clonedQuery); }
/** * The query must be cloned, and the sub-expression must be cloned using the same outer expression identity. */ @Override protected void postCopyIn(Map alreadyDone) { initializeCountSubQuery(); super.postCopyIn(alreadyDone); ReportQuery clonedQuery = (ReportQuery)getSubQuery().clone(); if (!clonedQuery.isCallQuery()) { if (clonedQuery.getSelectionCriteria() != null) { clonedQuery.setSelectionCriteria(getSubQuery().getSelectionCriteria().copiedVersionFrom(alreadyDone)); // ensure the builder for the subquery is the same as the builder for the subquery's expression // for certain Subqueries (for instance batch queries for direct collections), when we get to this // point the builder for the clonedQuery will already be aliased. Replacing the builder with // the builder for the query's new expression solves this issue. if (clonedQuery.getExpressionBuilder() != null) { clonedQuery.setExpressionBuilder((ExpressionBuilder)clonedQuery.getExpressionBuilder().copiedVersionFrom(alreadyDone)); } } else if (clonedQuery.getExpressionBuilder() != null) { // Must clone the expression builder. clonedQuery.setExpressionBuilder((ExpressionBuilder)clonedQuery.getExpressionBuilder().copiedVersionFrom(alreadyDone)); } // Must also clone report items, group by, having, order by. clonedQuery.copyReportItems(alreadyDone); } setSubQuery(clonedQuery); }
}} reportQuery.setReferenceClass(((InternalSelection) this.selection).getCurrentNode().getBuilder().getQueryClass()); reportQuery.setExpressionBuilder(((InternalSelection) this.selection).getCurrentNode().getBuilder());
reportQuery.setShouldReturnWithoutReportQueryResult(true); reportQuery.setExpressionBuilder(((InternalSelection) this.selection.getCompoundSelectionItems().get(0)).getCurrentNode().getBuilder()); for (Selection nested : this.selection.getCompoundSelectionItems()) { if (((SelectionImpl) nested).isConstructor()) { ((InternalSelection) this.where).getCurrentNode().getBuilder().getQueryClass() != null) { reportQuery.setReferenceClass(((InternalSelection) this.where).getCurrentNode().getBuilder().getQueryClass()); reportQuery.setExpressionBuilder(((InternalSelection) this.where).getCurrentNode().getBuilder()); } else { reportQuery.setExpressionBuilder(((InternalSelection) this.selection.getCompoundSelectionItems().get(0)).getCurrentNode().getBuilder()); reportQuery.setReferenceClass(((InternalSelection) this.selection.getCompoundSelectionItems().get(0)).getCurrentNode().getBuilder().getQueryClass());
/** * Create a predicate that tests whether an element is not a member of a * collection. * * @param elem * element expression * @param collection * expression * @return predicate */ public <E, C extends Collection<E>> Predicate isNotMember(Expression<E> elem, Expression<C> collection){ ReportQuery subQuery = new ReportQuery(); subQuery.setReferenceClass(((ExpressionImpl)elem).getJavaType()); org.eclipse.persistence.expressions.ExpressionBuilder elemBuilder = new org.eclipse.persistence.expressions.ExpressionBuilder(); org.eclipse.persistence.expressions.Expression collectionExp =((InternalSelection)collection).getCurrentNode(); org.eclipse.persistence.expressions.Expression elemExp =((InternalSelection)elem).getCurrentNode(); subQuery.setExpressionBuilder(elemBuilder); subQuery.setShouldRetrieveFirstPrimaryKey(true); subQuery.setSelectionCriteria(elemBuilder.equal(collectionExp).and(collectionExp.equal(elemExp))); return new CompoundExpressionImpl(metamodel, ((InternalSelection)elem).getCurrentNode().notExists(subQuery), buildList(elem, collection), "isNotMemeber"); }
query.setExpressionBuilder(outerBuilder); subSelect.setSelectionCriteria(baseExp.equal(outerBuilder).and(query.getSelectionCriteria())); } else { outerBuilder = new ExpressionBuilder(newDescriptor.getJavaClass()); query.setExpressionBuilder(outerBuilder); subSelect.setSelectionCriteria(baseExp.equal(outerBuilder));
query.setExpressionBuilder(outerBuilder); subSelect.setSelectionCriteria(baseExp.equal(outerBuilder).and(query.getSelectionCriteria())); } else { outerBuilder = new ExpressionBuilder(newDescriptor.getJavaClass()); query.setExpressionBuilder(outerBuilder); subSelect.setSelectionCriteria(baseExp.equal(outerBuilder));
DatabaseMapping mapping = descriptor.getMappingForAttributeName(attribute); if (mapping != null && mapping.isDirectCollectionMapping()){ subQuery.setExpressionBuilder(baseExpression.getBuilder()); subQuery.setReferenceClass(sourceClass); subQuery.addCount(attribute, subQuery.getExpressionBuilder().anyOf(attribute), returnType);
DatabaseMapping mapping = descriptor.getMappingForAttributeName(attribute); if (mapping != null && mapping.isDirectCollectionMapping()){ subQuery.setExpressionBuilder(baseExpression.getBuilder()); subQuery.setReferenceClass(sourceClass); subQuery.addCount(attribute, subQuery.getExpressionBuilder().anyOf(attribute), returnType);