private void initializeReportQuery() { ReportQuery query = new ReportQuery(); query.returnWithoutReportQueryResult(); query.dontUseDistinct(); this.query = query; }
private void initializeReportQuery() { ReportQuery query = new ReportQuery(); query.returnWithoutReportQueryResult(); query.dontUseDistinct(); this.query = query; }
/** * INTERNAL: * return a collection of expressions if PK's are used. */ public Vector getQueryExpressions() { Vector fieldExpressions = NonSynchronizedVector.newInstance(getItems().size()); if (shouldSelectValue1()) { Expression one = new ConstantExpression(new Integer(1), new ExpressionBuilder()); this.addItem("one", one); this.dontUseDistinct(); fieldExpressions.addElement(one); } else // For bug 3115576 and an EXISTS subquery only need to return a single field. if (shouldRetrieveFirstPrimaryKey()) { if (!getDescriptor().getPrimaryKeyFields().isEmpty()) { fieldExpressions.addElement(getDescriptor().getPrimaryKeyFields().get(0)); } } if (shouldRetrievePrimaryKeys()) { fieldExpressions.addAll(getDescriptor().getPrimaryKeyFields()); } return fieldExpressions; }
/** * INTERNAL: * return a collection of expressions if PK's are used. */ public Vector getQueryExpressions() { Vector fieldExpressions = NonSynchronizedVector.newInstance(getItems().size()); if (shouldSelectValue1()) { Expression one = new ConstantExpression(Integer.valueOf(1), new ExpressionBuilder()); this.addItem("one", one); this.dontUseDistinct(); fieldExpressions.addElement(one); } else // For bug 3115576 and an EXISTS subquery only need to return a single field. if (shouldRetrieveFirstPrimaryKey()) { if (!getDescriptor().getPrimaryKeyFields().isEmpty()) { fieldExpressions.addElement(getDescriptor().getPrimaryKeyFields().get(0)); } } if (shouldRetrievePrimaryKeys()) { fieldExpressions.addAll(getDescriptor().getPrimaryKeyFields()); } return fieldExpressions; }
/** * INTERNAL * Generate the EclipseLink expression for this node */ public Expression generateExpression(GenerationContext context) { SubqueryNode subqueryNode = (SubqueryNode)getLeft(); ReportQuery reportQuery = subqueryNode.getReportQuery(context); // Replace the SELECT clause of the exists subquery by SELECT 1 to // avoid problems with databases not supporting multiple columns in the // subquery SELECT clause in SQL. // The original select clause expressions might include relationship // navigations which should result in FK joins in the generated SQL, // e.g. ... EXISTS (SELECT o.customer FROM Order o ...). Add the // select clause expressions as non fetch join attributes to the // ReportQuery representing the subquery. This make sure the FK joins // get generated. List items = reportQuery.getItems(); for (Iterator i = items.iterator(); i.hasNext();) { ReportItem item = (ReportItem)i.next(); Expression expr = item.getAttributeExpression(); reportQuery.addNonFetchJoinedAttribute(expr); } reportQuery.clearItems(); Expression one = new ConstantExpression(new Integer(1), new ExpressionBuilder()); reportQuery.addItem("one", one); reportQuery.dontUseDistinct(); Expression expr = context.getBaseExpression(); return notIndicated() ? expr.notExists(reportQuery) : expr.exists(reportQuery); }
/** * INTERNAL * Generate the EclipseLink expression for this node */ public Expression generateExpression(GenerationContext context) { SubqueryNode subqueryNode = (SubqueryNode)getLeft(); ReportQuery reportQuery = subqueryNode.getReportQuery(context); // Replace the SELECT clause of the exists subquery by SELECT 1 to // avoid problems with databases not supporting multiple columns in the // subquery SELECT clause in SQL. // The original select clause expressions might include relationship // navigations which should result in FK joins in the generated SQL, // e.g. ... EXISTS (SELECT o.customer FROM Order o ...). Add the // select clause expressions as non fetch join attributes to the // ReportQuery representing the subquery. This make sure the FK joins // get generated. List items = reportQuery.getItems(); for (Iterator i = items.iterator(); i.hasNext();) { ReportItem item = (ReportItem)i.next(); Expression expr = item.getAttributeExpression(); reportQuery.addNonFetchJoinedAttribute(expr); } reportQuery.clearItems(); Expression one = new ConstantExpression(Integer.valueOf(1), new ExpressionBuilder()); reportQuery.addItem("one", one); reportQuery.dontUseDistinct(); Expression expr = context.getBaseExpression(); return notIndicated() ? expr.notExists(reportQuery) : expr.exists(reportQuery); }
/** * INTERNAL * Generate the EclipseLink expression for this node */ public Expression generateExpression(GenerationContext context) { SubqueryNode subqueryNode = (SubqueryNode)getLeft(); ReportQuery reportQuery = subqueryNode.getReportQuery(context); // Replace the SELECT clause of the exists subquery by SELECT 1 to // avoid problems with databases not supporting multiple columns in the // subquery SELECT clause in SQL. // The original select clause expressions might include relationship // navigations which should result in FK joins in the generated SQL, // e.g. ... EXISTS (SELECT o.customer FROM Order o ...). Add the // select clause expressions as non fetch join attributes to the // ReportQuery representing the subquery. This make sure the FK joins // get generated. List items = reportQuery.getItems(); for (Iterator i = items.iterator(); i.hasNext();) { ReportItem item = (ReportItem)i.next(); Expression expr = item.getAttributeExpression(); reportQuery.addNonFetchJoinedAttribute(expr); } reportQuery.clearItems(); Expression one = new ConstantExpression(Integer.valueOf(1), new ExpressionBuilder()); reportQuery.addItem("one", one); reportQuery.dontUseDistinct(); Expression expr = context.getBaseExpression(); return notIndicated() ? expr.notExists(reportQuery) : expr.exists(reportQuery); }