Package org.eclipse.persistence.expressions

Examples of org.eclipse.persistence.expressions.ExpressionBuilder


      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();
View Full Code Here


    // 1) An abstract schema name (entity name) -> parsed as AbstractSchemaName
    // 2) A fully qualified class name -> parsed as a CollectionValuedPathExpression
    //    that cannot be visited
    if (declaration.isRange()) {
      type[0] = declaration.getDescriptor().getJavaClass();
      queryExpression = new ExpressionBuilder(type[0]);
    }
    // The FROM subquery needs to be created differently than a regular subquery
    else if (declaration.isSubquery()) {
      type[0] = null;
      queryExpression = declaration.getQueryExpression();
View Full Code Here

     * @param entity
     *            metamodel entity representing the entity of type X
     * @return query root corresponding to the given entity
     */
    public <X> Root<X> from(EntityType<X> entity){
        RootImpl root = new RootImpl<X>(entity, this.metamodel, entity.getBindableJavaType(), new ExpressionBuilder(entity.getBindableJavaType()), entity);
       integrateRoot(root);
        return root;
    }
View Full Code Here

        root.findJoins(this);
    }
   
    protected org.eclipse.persistence.expressions.Expression getBaseExpression() {
        if (this.roots.isEmpty()) {
            return new ExpressionBuilder();
        } else {
            return ((RootImpl)this.roots.iterator().next()).getCurrentNode();
        }
    }
View Full Code Here

      // The abstract schema name is now a CollectionValuedPathExpression, request the context
      // to return the Expression for the new Declaration
      return queryContext.getBaseExpression();
    }

    return new ExpressionBuilder(descriptor.getJavaClass());
  }
View Full Code Here

    /**
     * INTERNAL:
     * Build the selection criteria to join the source, relation, and target tables.
     */
    public Expression buildSelectionCriteriaAndAddFieldsToQueryInternal(ForeignReferenceMapping mapping, Expression criteria, boolean shouldAddTargetFields, boolean shouldAddFieldsToQuery) {
        Expression builder = new ExpressionBuilder();
        Expression linkTable = builder.getTable(this.relationTable);

        if (shouldAddTargetFields) {
            Iterator<DatabaseField> targetKeyIterator = getTargetKeyFields().iterator();
            Iterator<DatabaseField> relationKeyIterator = getTargetRelationKeyFields().iterator();
            while (targetKeyIterator.hasNext()) {
                DatabaseField relationKey = relationKeyIterator.next();
                DatabaseField targetKey = targetKeyIterator.next();   
                Expression expression = builder.getField(targetKey).equal(linkTable.getField(relationKey));   
                if (criteria == null) {
                    criteria = expression;
                } else {
                    criteria = expression.and(criteria);
                }
            }
        }

        Iterator<DatabaseField> relationKeyIterator = getSourceRelationKeyFields().iterator();
        Iterator<DatabaseField> sourceKeyIterator = getSourceKeyFields().iterator();

        while (relationKeyIterator.hasNext()) {
            DatabaseField relationKey = relationKeyIterator.next();
            DatabaseField sourceKey = sourceKeyIterator.next();           
            Expression expression = linkTable.getField(relationKey).equal(builder.getParameter(sourceKey));
            if (criteria == null) {
                criteria = expression;
            } else {
                criteria = expression.and(criteria);
            }
View Full Code Here

            return;
        }

        // Build where clause expression.
        Expression whereClause = null;
        Expression builder = new ExpressionBuilder();

        for (DatabaseField relationKey : getSourceRelationKeyFields()) {
            Expression expression = builder.getField(relationKey).equal(builder.getParameter(relationKey));
            whereClause = expression.and(whereClause);
        }

        if (mapping.isCollectionMapping()) {
            for (DatabaseField relationKey : getTargetRelationKeyFields()) {   
                Expression expression = builder.getField(relationKey).equal(builder.getParameter(relationKey));
                whereClause = expression.and(whereClause);
            }
        }

        SQLDeleteStatement statement = new SQLDeleteStatement();
View Full Code Here

    // If the derived expression is a class (non direct collection), then create a new expression
    // builder for it, this builder will be compared as equal to the outer reference
    if ((mapping != null) && (mapping.getReferenceDescriptor() != null)) {

      Expression expression = new ExpressionBuilder(mapping.getReferenceDescriptor().getJavaClass());
      queryContext.addUsedIdentificationVariable(rootPath);
      queryContext.addQueryExpression(rootPath, expression);

      // Check to see if the Expression exists in the parent's context,
      // if not, then create/cache a new instance
      JPQLQueryContext parentContext = queryContext.getParent();

      if (parentContext.getQueryExpressionImp(rootPath) == null) {
        parentContext.addQueryExpressionImp(rootPath, queryContext.buildExpression(baseExpression));
      }

      return expression;
    }
    else {

      // Otherwise it will be derived by duplicating the join to the outer builder inside the
      // sub select. The same could be done for direct collection, but difficult to create a
      // builder on a table. Retrieve the superquery identification variable from the derived path
      int index = rootPath.indexOf('.');
      String superqueryVariableName = rootPath.substring(0, index).toUpperCase().intern();

      // Create the local ExpressionBuilder for the super identification variable
      Expression expression = queryContext.getParent().findQueryExpressionImp(superqueryVariableName);

      expression = new ExpressionBuilder(expression.getBuilder().getQueryClass());
      queryContext.addUsedIdentificationVariable(superqueryVariableName);
      queryContext.addQueryExpression(superqueryVariableName, expression);

      // Now create the base Expression for the actual derived path
      return queryContext.buildExpression(baseExpression);
View Full Code Here

            public void postBuild(DescriptorEvent event) {
                FunctionExpression expression = (FunctionExpression)event.getObject();
                for (int index = 0; index < expression.getChildren().size(); index++) {
                    Expression child = (Expression)expression.getChildren().get(index);
                    if (child.isValueExpression()) {
                        child.setLocalBase(new ExpressionBuilder());
                    }
                }
                if (expression.getChildren().size() > 0) {
                    expression.setBaseExpression((Expression)expression.getChildren().get(0));
                }
                else {
                    expression.setBaseExpression(new ExpressionBuilder());
                }
            }
        });

        XMLDirectMapping operatorMapping = new XMLDirectMapping();
View Full Code Here

        // Retrieve the enum constant
        String path = expression.getPath(expression.pathSize() - 1);
        Enum<?> enumConstant = retrieveEnumConstant(enumType, path);

        // Create the Expression
        localExpression = new ConstantExpression(enumConstant, new ExpressionBuilder());

        return true;
      }

      return false;
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.expressions.ExpressionBuilder

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.