Package org.eclipse.persistence.jpa.jpql.parser

Examples of org.eclipse.persistence.jpa.jpql.parser.JPQLQueryBNF


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

    JPQLQueryBNF queryBNF = getQueryBNF(expression.getQueryBNF().getId());
    boolean validFunction = (queryBNF != null) && queryBNF.hasIdentifier(expression.getIdentifier());

    // JPA 1.0/2.0 does not support the function expression
    if (!isJPA2_1() || !validFunction) {
      addProblem(expression, FunctionExpression_InvalidJPAVersion);
    }
View Full Code Here


      int startPosition = position(expression);
      addProblem(expression, startPosition, InExpression_MissingExpression);
    }
    else {
      Expression leftExpression = expression.getExpression();
      JPQLQueryBNF queryBNF = getQueryBNF(expression.getExpressionExpressionQueryBNFId());

      // First check for nested array support
      if (isNestedArray(leftExpression)) {
        if (!queryBNF.handlesNestedArray()) {
          int startPosition = position(expression);
          int endPosition   = startPosition + length(leftExpression);
          addProblem(expression, startPosition, endPosition, InExpression_InvalidExpression);
        }
        else {
          leftExpression.accept(this);
        }
      }
      // Validate the expression
      else if (!isValid(leftExpression, queryBNF) || isDateTimeConstant(leftExpression)) {
        int startPosition = position(expression);
        int endPosition   = startPosition + length(leftExpression);
        addProblem(expression, startPosition, endPosition, InExpression_InvalidExpression);
      }
      else {
        leftExpression.accept(this);
      }
    }

    // Check for "IN :input_parameter" defined in JPA 2.0
    boolean singleInputParameter = isNewerThanOrEqual(JPAVersion.VERSION_2_0) &&
                                   expression.isSingleInputParameter();

    // Missing '('
    if (!expression.hasLeftParenthesis() && !singleInputParameter) {

      int startPosition = position(expression) +
                          length(expression.getExpression()) +
                          (expression.hasExpression() ? 1 : 0) +
                          (expression.hasNot() ? 4 /* NOT + whitespace */ : 0) +
                          2 /* IN */;

      addProblem(expression, startPosition, InExpression_MissingLeftParenthesis);
    }
    // There must be at least one element in the comma separated list that
    // defines the set of values for the IN expression.
    else if (!expression.hasInItems()) {

      int startPosition = position(expression) +
                          length(expression.getExpression()) +
                          (expression.hasExpression() ? 1 : 0) +
                          (expression.hasNot() ? 4 /* NOT + whitespace */ : 0) +
                          2 /* IN */ +
                          (expression.hasSpaceAfterIn() ? 1 : 0) +
                          (expression.hasLeftParenthesis() ? 1 : 0);

      addProblem(expression, startPosition, InExpression_MissingInItems);
    }
    // Make sure the IN items are separated by commas
    else if (!singleInputParameter) {

      Expression inItems = expression.getInItems();
      CollectionExpression collectionExpression = getCollectionExpression(inItems);

      // Validate the collection of items
      if (collectionExpression != null) {

        validateCollectionSeparatedByComma(
          inItems,
          InExpression_ItemEndsWithComma,
          InExpression_ItemIsMissingComma
        );

        // Validate each item
        JPQLQueryBNF queryBNF = getQueryBNF(expression.getExpressionItemQueryBNFId());
        int index = 0;

        for (Expression child : collectionExpression.children()) {

          index++;

          // First check for nested array support
          if (isNestedArray(child)) {
            if (!queryBNF.handlesNestedArray()) {
              addProblem(child, InExpression_ItemInvalidExpression, String.valueOf(index));
            }
            else {
              child.accept(this);
            }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jpa.jpql.parser.JPQLQueryBNF

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.