Package org.datanucleus.query.expression

Examples of org.datanucleus.query.expression.PrimaryExpression


                }
            }
        }
        else if (expr instanceof PrimaryExpression)
        {
            PrimaryExpression primExpr = (PrimaryExpression)expr;
            String id = primExpr.getId();
            if (id.equals("this"))
            {
                return true;
            }
            for (int j=0;j<exprGrouping.length;j++)
View Full Code Here


            str.append(")");
            return str.toString();
        }
        else if (expr instanceof PrimaryExpression)
        {
            PrimaryExpression primExpr = (PrimaryExpression)expr;
            if (primExpr.getLeft() != null)
            {
                return JDOQLQueryHelper.getJDOQLForExpression(primExpr.getLeft()) + "." + primExpr.getId();
            }
            return primExpr.getId();
        }
        else if (expr instanceof ParameterExpression)
        {
            ParameterExpression paramExpr = (ParameterExpression)expr;
            if (paramExpr.getId() != null)
View Full Code Here

                        jt = org.datanucleus.query.expression.JoinExpression.JoinType.JOIN_RIGHT_OUTER;
                    }

                    Attribute attr = join.getAttribute();
                    tuples.add(attr.getName());
                    PrimaryExpression primExpr = new PrimaryExpression(new ArrayList(tuples));
                    JoinExpression joinExpr = new JoinExpression(primExpr, join.getAlias(), jt);
                    if (currentExpr instanceof ClassExpression)
                    {
                        ((ClassExpression)currentExpr).setJoinExpression(joinExpr);
                    }
                    else
                    {
                        ((JoinExpression)currentExpr).setJoinExpression(joinExpr);
                    }

                    currentExpr = joinExpr;
                }
            }

            if (fetchJoins != null && !fetchJoins.isEmpty())
            {
                List tuples = new ArrayList();
                tuples.add(getAlias());

                Iterator<Fetch<X, ?>> iter = fetchJoins.iterator();
                Expression currentExpr = expr;
                while (iter.hasNext())
                {
                    Fetch<X, ?> join = iter.next();
                    org.datanucleus.query.expression.JoinExpression.JoinType jt = org.datanucleus.query.expression.JoinExpression.JoinType.JOIN_INNER;
                    if (join.getJoinType() == JoinType.LEFT)
                    {
                        jt = org.datanucleus.query.expression.JoinExpression.JoinType.JOIN_LEFT_OUTER;
                    }
                    else if (join.getJoinType() == JoinType.RIGHT)
                    {
                        jt = org.datanucleus.query.expression.JoinExpression.JoinType.JOIN_RIGHT_OUTER;
                    }

                    Attribute attr = join.getAttribute();
                    tuples.add(attr.getName());
                    PrimaryExpression primExpr = new PrimaryExpression(new ArrayList(tuples));
                    JoinExpression joinExpr = new JoinExpression(primExpr, null, jt);
                    if (currentExpr instanceof ClassExpression)
                    {
                        ((ClassExpression)currentExpr).setJoinExpression(joinExpr);
                    }
                    else
                    {
                        ((JoinExpression)currentExpr).setJoinExpression(joinExpr);
                    }

                    currentExpr = joinExpr;
                }
            }
            return expr;
        }
        else
        {
            List tuples = new ArrayList();
            String alias = getAlias();
            if (alias != null)
            {
                // Specified with an alias, so just use the alias
                tuples.add(getAlias());
            }
            else
            {
                String fieldName = attribute.getMetadata().getName();
                if (parent != null)
                {
                    // TODO What about multiple field usage "a.b.c" ?
                    tuples.add(parent.getAlias());
                    tuples.add(fieldName);
                    return new PrimaryExpression(tuples);
                }
            }
            return new PrimaryExpression(tuples);
        }
    }
View Full Code Here

        } else {
          // May need non-key for this
          keysOnly = false;
        }
      } else if (resultExpr instanceof PrimaryExpression) {
        PrimaryExpression primaryExpr = (PrimaryExpression) resultExpr;
        if (!primaryExpr.getId().equals(compilation.getCandidateAlias())) {
          AbstractMemberMetaData ammd =
            getMemberMetaDataForTuples(acmd, getTuples(primaryExpr, compilation.getCandidateAlias()));
          if (ammd == null) {
            throw noMetaDataException(primaryExpr.getId(), acmd.getFullClassName());
          }
          if (!ammd.isPrimaryKey()) {
            keysOnly = false;
          }
        }
View Full Code Here

   * @param qd The QueryData
   * @param orderExpr The OrderExpression
   * @return The name of the sort property that was added to the primary datastore query.
   */
  String getSortProperty(QueryData qd, OrderExpression orderExpr) {
    PrimaryExpression left = (PrimaryExpression) orderExpr.getLeft();
    AbstractClassMetaData acmd = qd.acmd;
    List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias());
    if (isJoin(left.getLeft(), tuples)) {
      // Change the class meta data to the meta-data for the joined class
      acmd = getJoinClassMetaData(left.getLeft(), tuples, qd);
    }

    AbstractMemberMetaData ammd = getMemberMetaDataForTuples(acmd, tuples);
    if (ammd == null) {
      throw noMetaDataException(left.getId(), acmd.getFullClassName());
    }
    if (MetaDataUtils.isParentPKField(ammd)) {
      throw new UnsupportedDatastoreFeatureException("Cannot sort by parent.");
    } else {
      String sortProp;
View Full Code Here

      // TODO Support escape syntax
      throw new UnsupportedDatastoreFeatureException("GAE doesn't currently support ESCAPE syntax (" + escapeParam + ")");
    }

    if (invokeExpr.getLeft() instanceof PrimaryExpression) {
      PrimaryExpression leftExpr = (PrimaryExpression)invokeExpr.getLeft();

      // Make sure that the left expression is a String
      List<String> tuples = getTuples(leftExpr, qd.compilation.getCandidateAlias());
      if (tuples.size() == 1) {
        // Handle case of simple field name
View Full Code Here

  private void handleStartsWithOperation(InvokeExpression invokeExpr, QueryData qd) {
    Expression param = (Expression) invokeExpr.getArguments().get(0);
    param.bind(getSymbolTable());

    if (invokeExpr.getLeft() instanceof PrimaryExpression) {
      PrimaryExpression left = (PrimaryExpression) invokeExpr.getLeft();

      // Make sure that the left expression is a String
      List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias());
      if (tuples.size() == 1) {
        // Handle case of simple field name
View Full Code Here

  private void handleContainsOperation(InvokeExpression invokeExpr, QueryData qd) {
    Expression param = (Expression) invokeExpr.getArguments().get(0);
    param.bind(getSymbolTable());

    if (invokeExpr.getLeft() instanceof PrimaryExpression) {
      PrimaryExpression left = (PrimaryExpression) invokeExpr.getLeft();

      // Make sure that the left expression is a collection
      List<String> tuples = getTuples(left, qd.compilation.getCandidateAlias());
      if (tuples.size() == 1) {
        // Handle case of simple field name
View Full Code Here

    tuples.remove(0);
    return getMetaDataManager().getMetaDataForClass(sym.getValueType(), getClassLoaderResolver());
  }

  private OrderExpression createJoinOrderExpression(PrimaryExpression expression) {
    PrimaryExpression primaryOrderExpr = new PrimaryExpression(expression.getTuples());
    return new OrderExpression(primaryOrderExpr);
  }
View Full Code Here

            throw newAggregateAndRowResultsException();
          }
          if (resultType == null) {
            resultType = ResultType.KEYS_ONLY;
          }
          PrimaryExpression primaryExpr = (PrimaryExpression) resultExpr;
          if (!primaryExpr.getId().equals(compilation.getCandidateAlias())) {
            AbstractMemberMetaData ammd =
                getMemberMetaData(acmd, getTuples(primaryExpr, compilation.getCandidateAlias()));
            if (ammd == null) {
              throw noMetaDataException(primaryExpr.getId(), acmd.getFullClassName());
            }
            projectionFields.add(primaryExpr.getId());
            if (ammd.getParent() instanceof EmbeddedMetaData || !ammd.isPrimaryKey()) {
              // A single non-pk field locks the result type on entity projection
              resultType = ResultType.ENTITY_PROJECTION;
            }
          }
View Full Code Here

TOP

Related Classes of org.datanucleus.query.expression.PrimaryExpression

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.