Class SelectStatementStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.SelectStatementStateObject
- All Implemented Interfaces:
StateObject
This state object represents a select statement, which has at least a
SELECT
clause and a FROM
clause. The other clauses are optional.
BNF: select_statement ::= select_clause from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause]
- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notify the state object representing theORDER BY
clause has changed.Fields inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject
GROUP_BY_CLAUSE_PROPERTY, HAVING_CLAUSE_PROPERTY, WHERE_CLAUSE_PROPERTY
-
Constructor Summary
ConstructorDescriptionCreates a newSelectStatementStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(StateObjectVisitor visitor) Visits thisStateObject
by the givenvisitor
.protected void
addChildren
(List<StateObject> children) Adds the children of thisStateObject
to the given list.Adds theORDER BY
clause.addOrderByClause
(String jpqlFragment) Adds theORDER BY
clause and parses the given JPQL fragment, which should represent one or many ordering items.addSelectItem
(String path) Adds the given path as a select item, which can either be an identification variable or a state-field path expression.addSelectItem
(String jpqlFragment, String resultVariable) Adds the given expression as a select item.void
addSelectItem
(StateObject stateObject) Adds the givenStateObject
as a select item.addSelectItem
(StateObject stateObject, String resultVariable) Adds the givenStateObject
as a select item.addSelectItemAs
(String jpqlFragment, String resultVariable) Adds the given expression as a select item.addSelectItemAs
(StateObject stateObject, String resultVariable) Adds the givenStateObject
as a select item.protected AbstractFromClauseStateObject
Creates the state object representing theFROM
clause.protected AbstractSelectClauseStateObject
Creates the state object representing theSELECT
clause.Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.Returns the state object representing theFROM
clause.Returns the state object representing theORDER BY
clause.Returns the parent of thisStateObject
.Creates and returns a newISelectExpressionStateObjectBuilder
that can be used to programmatically create a single select expression and once the expression is complete,ISelectExpressionStateObjectBuilder.commit()
will push theStateObject
representation of that expression as this clause's select expression.Returns the state object representing theSELECT
clause.boolean
Returns the state object representing theORDER BY
clause.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.void
Removes theORDER BY
clause.void
setExpression
(SelectStatement expression) Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.void
Either adds or removes theORDER BY
clause.protected void
toTextInternal
(Appendable writer) Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject
addCollectionDeclaration, addCollectionDeclaration, addGroupByClause, addGroupByClause, addHavingClause, addHavingClause, addRangeDeclaration, addRangeDeclaration, addRangeDeclaration, addWhereClause, addWhereClause, declarations, findIdentificationVariable, getDeclaration, getGroupByClause, getHavingClause, getWhereClause, hasGroupByClause, hasHavingClause, hasWhereClause, identificationVariables, initialize, parseSelect, removeGroupByClause, removeHavingClause, removeWhereClause, toggleGroupByClause, toggleHavingClause, toggleWhereClause
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
ORDER_BY_CLAUSE_PROPERTY
Notify the state object representing theORDER BY
clause has changed.- See Also:
-
-
Constructor Details
-
SelectStatementStateObject
Creates a newSelectStatementStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
accept
Description copied from interface:StateObject
Visits thisStateObject
by the givenvisitor
.- Parameters:
visitor
- Thevisitor
to visit this object
-
addChildren
Description copied from class:AbstractStateObject
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractSelectStatementStateObject
- Parameters:
children
- The list used to store the children
-
addOrderByClause
Adds theORDER BY
clause. The clause is not added if it's already present.- Returns:
- The state object representing the
ORDER BY
clause
-
addOrderByClause
Adds theORDER BY
clause and parses the given JPQL fragment, which should represent one or many ordering items. The clause is not added if it's already present.- Parameters:
jpqlFragment
- The fragment of the JPQL to parse that represents the ordering items, the fragment cannot start withORDER BY
- Returns:
- The
OrderByClauseStateObject
-
addSelectItem
Adds the givenStateObject
as a select item.- Parameters:
stateObject
- TheStateObject
representing a select expression
-
addSelectItem
Adds the givenStateObject
as a select item.- Parameters:
stateObject
- TheStateObject
representing the select expressionresultVariable
- The result variable identifying the select expression- Returns:
- The newly created
ResultVariableStateObject
-
addSelectItem
Adds the given path as a select item, which can either be an identification variable or a state-field path expression.- Parameters:
path
- The select expression to parse as a select item- Returns:
- The
StateObject
encapsulating the given path
-
addSelectItem
Adds the given expression as a select item.- Parameters:
jpqlFragment
- The select expression to parse as a select itemresultVariable
- The result variable identifying the select expression- Returns:
- The newly created
ResultVariableStateObject
-
addSelectItemAs
Adds the givenStateObject
as a select item.- Parameters:
stateObject
- TheStateObject
representing the select expressionresultVariable
- The result variable identifying the select expression- Returns:
- The newly created
ResultVariableStateObject
-
addSelectItemAs
Adds the given expression as a select item.- Parameters:
jpqlFragment
- The portion of a JPQL query that represents a select expressionresultVariable
- The result variable identifying the select expression- Returns:
- The newly created
ResultVariableStateObject
-
buildFromClause
Description copied from class:AbstractSelectStatementStateObject
Creates the state object representing theFROM
clause.- Specified by:
buildFromClause
in classAbstractSelectStatementStateObject
- Returns:
- A concrete instance of
AbstractFromClauseStateObject
-
buildSelectClause
Description copied from class:AbstractSelectStatementStateObject
Creates the state object representing theSELECT
clause.- Specified by:
buildSelectClause
in classAbstractSelectStatementStateObject
- Returns:
- A concrete instance of
AbstractSelectClauseStateObject
-
getExpression
Description copied from interface:StateObject
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpression
in interfaceStateObject
- Overrides:
getExpression
in classAbstractSelectStatementStateObject
- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObject
ornull
when the JPQL query is manually created (i.e. not from a string)
-
getFromClause
Description copied from class:AbstractSelectStatementStateObject
Returns the state object representing theFROM
clause.- Overrides:
getFromClause
in classAbstractSelectStatementStateObject
- Returns:
- The state object representing the
FROM
clause, which is nevernull
-
getOrderByClause
Returns the state object representing theORDER BY
clause.- Returns:
- Either the actual state object representing the
ORDER BY
clause ornull
if it's not present
-
getParent
Description copied from interface:StateObject
Returns the parent of thisStateObject
.- Specified by:
getParent
in interfaceStateObject
- Overrides:
getParent
in classAbstractStateObject
- Returns:
- Returns the parent of this
StateObject
, which isnull
only when this is the root of the hierarchy
-
getSelectBuilder
Creates and returns a newISelectExpressionStateObjectBuilder
that can be used to programmatically create a single select expression and once the expression is complete,ISelectExpressionStateObjectBuilder.commit()
will push theStateObject
representation of that expression as this clause's select expression.- Returns:
- A new builder that can be used to quickly create a select expression
-
getSelectClause
Description copied from class:AbstractSelectStatementStateObject
Returns the state object representing theSELECT
clause.- Overrides:
getSelectClause
in classAbstractSelectStatementStateObject
- Returns:
- Either the actual state object representing the
SELECT
clause, which is nevernull
-
hasOrderByClause
public boolean hasOrderByClause()Returns the state object representing theORDER BY
clause.- Returns:
true
if theORDER BY
clause is present;false
otherwise
-
isEquivalent
Description copied from interface:StateObject
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classAbstractSelectStatementStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
removeOrderByClause
public void removeOrderByClause()Removes theORDER BY
clause. -
setExpression
Keeps a reference of theparsed object
object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects
.- Parameters:
expression
- Theparsed object
representing aSELECT
statement
-
toggleOrderByClause
public void toggleOrderByClause()Either adds or removes theORDER BY
clause. -
toTextInternal
Description copied from class:AbstractStateObject
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Overrides:
toTextInternal
in classAbstractSelectStatementStateObject
- Parameters:
writer
- The writer used to print out the string representation- Throws:
IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-