Class SelectStatement

  • All Implemented Interfaces:
    Expression

    public final class SelectStatement
    extends AbstractSelectStatement
    A SELECT query is an operation that retrieves data from one or more tables or views.

    JPA:

    BNF: select_statement ::= select_clause from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause]

    EclipseLink 2.4:

    BNF: select_statement ::= select_clause from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause] {union_clause}*

    HQL query (EclipseLink 2.5):

    BNF: select_statement ::= [select_clause] from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause] {union_clause}*

    Version:
    2.5
    See Also:
    FromClause, GroupByClause, HavingClause, HierarchicalQueryClause, OrderByClause, SelectClause, UnionClause, WhereClause
    Author:
    Pascal Filion
    Since:
    2.3
    • Constructor Detail

      • SelectStatement

        public SelectStatement​(AbstractExpression parent)
        Creates a new SelectStatement.
        Parameters:
        parent - The parent of this expression
    • Method Detail

      • buildFromClause

        protected FromClause buildFromClause()
        Creates the expression representing the from clause of this select statement.
        Specified by:
        buildFromClause in class AbstractSelectStatement
        Returns:
        A new from clause, null can't be returned
      • buildSelectClause

        protected SelectClause buildSelectClause()
        Creates the expression representing the select clause of this select statement.
        Specified by:
        buildSelectClause in class AbstractSelectStatement
        Returns:
        A new from clause, null can't be returned
      • getOrderByClause

        public Expression getOrderByClause()
        Returns the Expression representing the ORDER BY clause.
        Returns:
        The expression representing the ORDER BY clause
      • getUnionClauses

        public Expression getUnionClauses()
        Returns the Expression representing the UNION clauses.
        Returns:
        The Expression representing the UNION clauses
      • hasOrderByClause

        public boolean hasOrderByClause()
        Determines whether the ORDER BY clause is defined or not.
        Returns:
        true if the query that got parsed had the ORDER BY clause
      • hasSpaceBeforeOrderBy

        public boolean hasSpaceBeforeOrderBy()
        Determines whether a whitespace was parsed before the ORDER BY clause. In some cases, the space could be owned by a child of the previous clause.
        Returns:
        true if there was a whitespace before the ORDER BY; false otherwise
      • hasSpaceBeforeUnion

        public boolean hasSpaceBeforeUnion()
        Determines whether a whitespace was parsed before the UNION clause. In some cases, the space could be owned by a child of the previous clause.
        Returns:
        true if there was a whitespace before the UNION; false otherwise
      • hasUnionClauses

        public boolean hasUnionClauses()
        Determines whether at least one UNION clause was defined.
        Returns:
        true if the query that got parsed had the UNION clauses
      • isParsingComplete

        protected boolean isParsingComplete​(WordParser wordParser,
                                            java.lang.String word,
                                            Expression expression)
        Determines whether the parsing is complete based on what is left in the given text. The text is never empty.
        Overrides:
        isParsingComplete in class AbstractExpression
        Parameters:
        wordParser - The text to parse based on the current position of the cursor
        word - The word that was retrieved from the given text, which is the first word in the text
        expression - The Expression that has already been parsed
        Returns:
        true if the text no longer can't be parsed by the current expression; false if more can be parsed
      • parse

        protected void parse​(WordParser wordParser,
                             boolean tolerant)
        Parses the query by starting at the current position, which is part of the given WordParser.
        Overrides:
        parse in class AbstractSelectStatement
        Parameters:
        wordParser - The text to parse based on the current position of the cursor
        tolerant - Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
      • toParsedText

        protected void toParsedText​(java.lang.StringBuilder writer,
                                    boolean actual)
        Generates a string representation of this Expression, including its children, if it has any.
        Overrides:
        toParsedText in class AbstractSelectStatement
        Parameters:
        writer - The buffer used to append this Expression's string representation
        actual - Determines whether the string representation should represent what was parsed, i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the JPQL identifiers