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


  protected boolean areArithmeticSymbolsAppendable(Expression expression) {
    return isValid(expression, ArithmeticTermBNF.ID);
  }

  protected boolean areComparisonSymbolsAppendable(Expression expression) {
    JPQLQueryBNF queryBNF = getQueryBNF(ComparisonExpressionBNF.ID);
    queryBNF.setCompound(false);
    try {
      return isValid(expression, queryBNF);
    }
    finally {
      queryBNF.setCompound(true);
    }
  }
View Full Code Here

   * @param expression The {@link Expression} is used to determine the {@link JPQLQueryBNF} to use
   * when retrieving the JPQL identifiers representing a function
   */
  protected void addFunctionIdentifiers(Expression expression) {

    JPQLQueryBNF queryBNF = expression.getParent().findQueryBNF(expression);

    addIdentificationVariables();
    addFunctionIdentifiers(queryBNF);

    if (isValid(queryBNF, SubqueryBNF.ID, true) && isEncapsulated(expression)) {
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

   * {@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

  }

  protected boolean isValidWithFindQueryBNF(AbstractExpression expression, String queryBNF) {
    JPQLQueryBNFValidator validator = getExpressionValidator(queryBNF);
    try {
      JPQLQueryBNF childQueryBNF = expression.getParent().findQueryBNF(expression);
      validator.validate(childQueryBNF);
      return validator.valid;
    }
    finally {
      validator.valid = false;
View Full Code Here

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

    JPQLQueryBNF queryBNF = getQueryBNF(expression.getQueryBNF().getId());
    boolean validFunction = (queryBNF != null) && queryBNF.getIdentifiers().contains(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

  protected boolean areArithmeticSymbolsAppendable(Expression expression) {
    return isValid(expression, ArithmeticTermBNF.ID);
  }

  protected boolean areComparisonSymbolsAppendable(Expression expression) {
    JPQLQueryBNF queryBNF = getQueryBNF(ComparisonExpressionBNF.ID);
    queryBNF.setCompound(false);
    try {
      return isValid(expression, queryBNF);
    }
    finally {
      queryBNF.setCompound(true);
    }
  }
View Full Code Here

  }

  protected boolean isValidWithFindQueryBNF(AbstractExpression expression, String queryBNF) {
    JPQLQueryBNFValidator validator = getExpressionValidator(queryBNF);
    try {
      JPQLQueryBNF childQueryBNF = expression.getParent().findQueryBNF(expression);
      validator.validate(childQueryBNF);
      return validator.isValid();
    }
    finally {
      validator.dispose();
View Full Code Here

   * @param expression The {@link Expression} is used to determine the {@link JPQLQueryBNF} to use
   * when retrieving the JPQL identifiers representing a function
   */
  protected void addFunctionIdentifiers(Expression expression) {

    JPQLQueryBNF queryBNF = expression.getParent().findQueryBNF(expression);

    addIdentificationVariables();
    addFunctionIdentifiers(queryBNF);

    if (isValid(queryBNF, SubqueryBNF.ID, true) && isEncapsulated(expression)) {
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.