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

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


  }

  protected void initializeRoot() {

    if (jpqlExpression == null) {
      jpqlExpression = new JPQLExpression(query.getExpression(), jpqlGrammar, true);
    }

    currentQuery = jpqlExpression;
    contexts.put(currentQuery, this);
  }
View Full Code Here


    sb.append(TRIM);
    sb.append(LEFT_PARENTHESIS);
    sb.append(jpqlFragment);
    sb.append(RIGHT_PARENTHESIS);

    JPQLExpression jpqlExpression = new JPQLExpression(
      sb,
      getGrammar(),
      FunctionsReturningStringsBNF.ID,
      true
    );

    TrimExpression trimExpression = (TrimExpression) jpqlExpression.getQueryStatement();
    setSpecification(trimExpression.getSpecification());
    parseTrimCharacter(trimExpression.getTrimCharacter().toParsedText());
    super.parse(trimExpression.getExpression().toParsedText());

    // The trim character is actually the string primary
View Full Code Here

   *
   * @return The root of the parsed tree
   */
  public JPQLExpression getExpression() {
    if (jpqlExpression == null) {
      jpqlExpression = new JPQLExpression(getJPQLFragment(), jpqlGrammar, isTolerant());
    }
    return jpqlExpression;
  }
View Full Code Here

                                           String selectionCriteria,
                                           AbstractSession session) {

    try {
      // Create the parsed tree representation of the selection criteria
      JPQLExpression jpqlExpression = new JPQLExpression(
        selectionCriteria,
        DefaultEclipseLinkJPQLGrammar.instance(),
        ConditionalExpressionBNF.ID,
        isTolerant()
      );

      // Caches the info and add a virtual range variable declaration
      JPQLQueryContext queryContext = new JPQLQueryContext(jpqlGrammar());
      queryContext.cache(session, null, jpqlExpression, selectionCriteria);
      queryContext.addRangeVariableDeclaration(entityName, "this");

      // Validate the JPQL query, which will use the JPQL grammar matching the validation
      // level, for now, only validate the query statement because there could be an unknown
      // ending that is an order by clause
      validate(queryContext, jpqlExpression.getQueryStatement());

      // Create the Expression representing the selection criteria
      return queryContext.buildExpression(jpqlExpression.getQueryStatement());
    }
    catch (JPQLException exception) {
      throw exception;
    }
    catch (Exception exception) {
View Full Code Here

                                         DatabaseQuery query,
                                         AbstractSession session) {

    try {
      // Parse the JPQL query with the most recent JPQL grammar
      JPQLExpression jpqlExpression = new JPQLExpression(
        jpqlQuery,
        DefaultEclipseLinkJPQLGrammar.instance(),
        isTolerant()
      );

      // Create a context that caches the information contained in the JPQL query
      // (especially from the FROM clause)
      JPQLQueryContext queryContext = new JPQLQueryContext(jpqlGrammar());
      queryContext.cache(session, query, jpqlExpression, jpqlQuery);

      // Validate the JPQL query, which will use the JPQL grammar matching the validation level
      validate(queryContext, jpqlExpression);

      // Create the DatabaseQuery by visiting the parsed tree
      DatabaseQueryVisitor visitor = new DatabaseQueryVisitor(queryContext, jpqlQuery);
      jpqlExpression.accept(visitor);

      // Add the input parameter types to the DatabaseQuery
      if (query == null) {
        query = queryContext.getDatabaseQuery();
        addArguments(queryContext, query);
View Full Code Here

                                               CharSequence jpqlQuery,
                                               String queryBNFId,
                                               boolean tolerant) {

    // First parse the JPQL query
    JPQLExpression jpqlExpression = parse(jpqlQuery, getGrammar(), tolerant);

    // Now visit the parsed expression and create the state object hierarchy
    BasicStateObjectBuilder builder = getStateObjectBuilder();

    try {
      builder.jpqlQueryBuilder    = this;
      builder.managedTypeProvider = provider;

      jpqlExpression.accept(wrap(builder));

      return builder.parent;
    }
    finally {
      builder.jpqlQueryBuilder    = null;
View Full Code Here

  public StateObject buildStateObject(StateObject parent,
                                      CharSequence jpqlFragment,
                                      String queryBNFId) {

    // First parse the JPQL fragment
    JPQLExpression jpqlExpression = parse(jpqlFragment, parent.getGrammar(), queryBNFId);

    // We keep track of the old stuff because during the creation of a JPQLQueryStateObject,
    // it is possible the state model uses this builder to create some objects
    BasicStateObjectBuilder builder  = getStateObjectBuilder();
    IJPQLQueryBuilder oldBuilder     = builder.jpqlQueryBuilder;
    IManagedTypeProvider oldProvider = builder.managedTypeProvider;
    JPQLQueryStateObject oldParent   = builder.parent;
    StateObject oldStateObject       = builder.stateObject;

    try {
      builder.jpqlQueryBuilder    = this;
      builder.managedTypeProvider = parent.getManagedTypeProvider();
      builder.parent              = parent.getRoot();
      builder.stateObject         = parent;

      // Visit the Expression for which a StateObject is needed
      jpqlExpression.getQueryStatement().accept(wrap(builder));

      return builder.stateObject;
    }
    finally {
      builder.jpqlQueryBuilder    = oldBuilder;
View Full Code Here

   * @param tolerant Determines if the parsing system should be tolerant, meaning if it should try
   * to parse invalid or incomplete queries
   * @return The root of the parsed tree representation of the JPQL query
   */
  protected JPQLExpression parse(CharSequence jpqlQuery, JPQLGrammar jpqlGrammar, boolean tolerant) {
    return new JPQLExpression(jpqlQuery, jpqlGrammar, tolerant);
  }
View Full Code Here

   */
  protected JPQLExpression parse(CharSequence jpqFragment,
                                 JPQLGrammar jpqlGrammar,
                                 String queryBNFId) {

    return new JPQLExpression(jpqFragment, jpqlGrammar, queryBNFId, true);
  }
View Full Code Here

   */
  public ContentAssistProposals buildProposals(int position) {

    try {

      JPQLExpression jpqlExpression = queryContext.getJPQLExpression();
      String jpqlQuery = queryContext.getJPQLQuery();

      // Calculate the position of the cursor within the parsed tree
      queryPosition = jpqlExpression.buildPosition(jpqlQuery, position);

      // Retrieve the word from the JPQL query (which is the text before the position of the cursor)
      wordParser = new WordParser(jpqlQuery);
      wordParser.setPosition(position);
      word = wordParser.partialWord();
View Full Code Here

TOP

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

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.