Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public final Class SelectStatement

extends AbstractSelectStatement
Class Inheritance
Imports
java.util.Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser

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}*
Author
Pascal Filion
Since
2.3
Version
2.5
See Also
FromClause, GroupByClause, HavingClause, HierarchicalQueryClause, OrderByClause, SelectClause, UnionClause, WhereClause

Field Summary

Modifier and TypeField and Description
private boolean
hasSpaceBeforeOrderBy

Determines whether there is a whitespace after the select statement parsed by the superclass and the ORDER BY identifier.

private boolean
hasSpaceBeforeUnion

Determines whether there is a whitespace after the select statement parsed by the superclass and the UNION identifier.

private AbstractExpression
orderByClause

The ORDER BY expression.

private AbstractExpression
unionClauses

The UNION expression.

Constructor Summary

AccessConstructor and Description
public
SelectStatement(AbstractExpression
The parent of this expression
parent
)

Creates a new SelectStatement.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ExpressionVisitor
The ExpressionVisitor to visit this object
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.
public void
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
protected FromClause
buildFromClause()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildFromClause.

Creates the expression representing the from clause of this select statement.
protected SelectClause
buildSelectClause()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildSelectClause.

Creates the expression representing the select clause of this select statement.
public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public Expression

Returns:

The expression representing the ORDER BY clause
getOrderByClause
()

Returns the Expression representing the ORDER BY clause.

public JPQLQueryBNF
public Expression

Returns:

The Expression representing the UNION clauses
getUnionClauses
()

Returns the Expression representing the UNION clauses.

public boolean

Returns:

true if the query that got parsed had the ORDER BY clause
hasOrderByClause
()

Determines whether the ORDER BY clause is defined or not.

public boolean

Returns:

true if there was a whitespace before the ORDER BY; false otherwise
hasSpaceBeforeOrderBy
()

Determines whether a whitespace was parsed before the ORDER BY clause.

public boolean

Returns:

true if there was a whitespace before the UNION; false otherwise
hasSpaceBeforeUnion
()

Determines whether a whitespace was parsed before the UNION clause.

public boolean

Returns:

true if the query that got parsed had the UNION clauses
hasUnionClauses
()

Determines whether at least one UNION clause was defined.

protected boolean
isParsingComplete(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The word that was retrieved from the given text, which is the first word in the text
word
,
Expression
The Expression that has already been parsed
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text.
protected void
parse(WordParser
The text to parse based on the current position of the cursor
wordParser
,
boolean
Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries
tolerant
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
protected void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
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
actual
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement:
getFromClausegetGroupByClausegetHavingClausegetSelectClausegetWhereClausehasFromClausehasGroupByClausehasHavingClausehasSelectClausehasSpaceAfterFromhasSpaceAfterGroupByhasSpaceAfterSelecthasSpaceAfterWherehasWhereClauseshouldManageSpaceAfterClause

Field Detail

hasSpaceBeforeOrderByback to summary
private boolean hasSpaceBeforeOrderBy

Determines whether there is a whitespace after the select statement parsed by the superclass and the ORDER BY identifier.

hasSpaceBeforeUnionback to summary
private boolean hasSpaceBeforeUnion

Determines whether there is a whitespace after the select statement parsed by the superclass and the UNION identifier.

orderByClauseback to summary
private AbstractExpression orderByClause

The ORDER BY expression.

unionClausesback to summary
private AbstractExpression unionClauses

The UNION expression.

Constructor Detail

SelectStatementback to summary
public SelectStatement(AbstractExpression parent)

Creates a new SelectStatement.

Parameters
parent:AbstractExpression

The parent of this expression

Method Detail

acceptback to summary
public void accept(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.

Parameters
visitor:ExpressionVisitor

The ExpressionVisitor to visit this object

Annotations
@Override
acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.acceptChildren.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
buildFromClauseback to summary
protected FromClause buildFromClause()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildFromClause.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildFromClause.

Creates the expression representing the from clause of this select statement.

Returns:FromClause

A new from clause, null can't be returned

Annotations
@Override
buildSelectClauseback to summary
protected SelectClause buildSelectClause()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildSelectClause.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.buildSelectClause.

Creates the expression representing the select clause of this select statement.

Returns:SelectClause

A new from clause, null can't be returned

Annotations
@Override
findQueryBNFback to summary
public JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getOrderByClauseback to summary
public Expression getOrderByClause()

Returns the Expression representing the ORDER BY clause.

Returns:Expression

The expression representing the ORDER BY clause

getQueryBNFback to summary
public JPQLQueryBNF getQueryBNF()

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Returns the BNF of this Expression.

Returns:JPQLQueryBNF

The JPQLQueryBNF, which represents the grammar of this Expression

Annotations
@Override
getUnionClausesback to summary
public Expression getUnionClauses()

Returns the Expression representing the UNION clauses.

Returns:Expression

The Expression representing the UNION clauses

hasOrderByClauseback to summary
public boolean hasOrderByClause()

Determines whether the ORDER BY clause is defined or not.

Returns:boolean

true if the query that got parsed had the ORDER BY clause

hasSpaceBeforeOrderByback to summary
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:boolean

true if there was a whitespace before the ORDER BY; false otherwise

hasSpaceBeforeUnionback to summary
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:boolean

true if there was a whitespace before the UNION; false otherwise

hasUnionClausesback to summary
public boolean hasUnionClauses()

Determines whether at least one UNION clause was defined.

Returns:boolean

true if the query that got parsed had the UNION clauses

isParsingCompleteback to summary
protected boolean isParsingComplete(WordParser wordParser, String word, Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.isParsingComplete.

Determines whether the parsing is complete based on what is left in the given text. The text is never empty.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

word:String

The word that was retrieved from the given text, which is the first word in the text

expression:Expression

The Expression that has already been parsed

Returns:boolean

true if the text no longer can't be parsed by the current expression; false if more can be parsed

Annotations
@Override
parseback to summary
protected void parse(WordParser wordParser, boolean tolerant)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
toParsedTextback to summary
protected void toParsedText(StringBuilder writer, boolean actual)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

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

Annotations
@Override