Package org.eclipse.persistence.queries

Examples of org.eclipse.persistence.queries.ReportQuery


     * INTERNAL
     * Generate the EclipseLink expression for this node
     */
    public Expression generateExpression(GenerationContext context) {
        SubqueryNode subqueryNode = (SubqueryNode)getLeft();
        ReportQuery reportQuery = subqueryNode.getReportQuery(context);

        Expression expr = context.getBaseExpression();
        return expr.all(reportQuery);
    }
View Full Code Here


     * INTERNAL
     * Apply this node to the passed query
     */
    public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) {
        if (theQuery.isReportQuery()) {
            ReportQuery reportQuery = (ReportQuery)theQuery;
            reportQuery.addAttribute(resolveAttribute(),
                                     generateExpression(context));
        }
    }
View Full Code Here

     * Apply this node to the passed query
     */
    public void applyToQuery(ObjectLevelReadQuery theQuery, GenerationContext context) {
        if (theQuery instanceof ReportQuery) {
            SelectGenerationContext selectContext = (SelectGenerationContext)context;
            ReportQuery reportQuery = (ReportQuery)theQuery;
            reportQuery.beginAddingConstructorArguments(
                getConstructorClass(context.getParseTreeContext()));
            for (Iterator i = constructorItems.iterator(); i.hasNext();) {
                Node node = (Node)i.next();
                if (selectingRelationshipField(node, context)) {
                    selectContext.useOuterJoins();
                }
                node.applyToQuery(reportQuery, context);
                selectContext.dontUseOuterJoins();
            }
            reportQuery.endAddingToConstructorItem();
        }
    }
View Full Code Here

        if (type == null) {
            throw new IllegalArgumentException("DynamicHelper.createQuery: Dynamic type not found: " + typeName);
        }

        return new ReportQuery(type.getJavaClass(), builder);
    }
View Full Code Here

        } else if (exp.isFunctionExpression()) {
            for (Expression e : (Vector<Expression>) ((FunctionExpression) exp).getChildren()) {
                updatePropertyParameterExpression(e);
            }
        } else if (exp.isSubSelectExpression()) {
            ReportQuery subSelectQuery = ((SubSelectExpression) exp).getSubQuery();
            for (ReportItem item : subSelectQuery.getItems()) {
                updatePropertyParameterExpression(item.getAttributeExpression());
            }
        }

        if (exp.isParameterExpression()) {
View Full Code Here

   * @return A fully initialized {@link ReportQuery}
   */
  ReportQuery buildSubquery(SimpleSelectStatement expression) {

    // First create the subquery
    ReportQuery subquery = new ReportQuery();
    queryContext.newSubQueryContext(expression, subquery);

    try {
      // Visit the subquery to populate it
      ReportQueryVisitor visitor = new ReportQueryVisitor(queryContext, subquery);
View Full Code Here

   * {@inheritDoc}
   */
  public void visit(AllOrAnyExpression expression) {

    // First create the subquery
    ReportQuery subquery = buildSubquery((SimpleSelectStatement) expression.getExpression());

    // Now create the ALL|SOME|ANY expression
    String identifier = expression.getIdentifier();
    queryExpression = queryContext.getBaseExpression();

View Full Code Here

                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());
            queryExpression = parentExpression.notExists(subQuery);
    }
    else {
      // Create the expression for the collection-valued path expression
      expression.getCollectionValuedPathExpression().accept(this);
View Full Code Here

   * {@inheritDoc}
   */
  public void visit(ExistsExpression expression) {

    // First create the subquery
    ReportQuery subquery = buildSubquery((SimpleSelectStatement) expression.getExpression());

    // 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
    for (ReportItem item : subquery.getItems()) {
      Expression expr = item.getAttributeExpression();
      subquery.addNonFetchJoinedAttribute(expr);
    }

    subquery.clearItems();

    Expression one = new ConstantExpression(1, new ExpressionBuilder());
    subquery.addItem("one", one);
    subquery.dontUseDistinct();

    // Now create the EXISTS expression
    queryExpression = queryContext.getBaseExpression();

    if (expression.hasNot()) {
View Full Code Here

   * {@inheritDoc}
   */
  public void visit(SimpleSelectStatement expression) {

    // First create the subquery
    ReportQuery subquery = buildSubquery(expression);

    // Now wrap the subquery
    queryExpression = queryContext.getBaseExpression();
    queryExpression = queryExpression.subQuery(subquery);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.queries.ReportQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.