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
FieldsModifier and TypeFieldDescriptionstatic final StringNotify the state object representing theORDER BYclause 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
ConstructorsConstructorDescriptionCreates a newSelectStatementStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.Adds theORDER BYclause.addOrderByClause(String jpqlFragment) Adds theORDER BYclause 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.voidaddSelectItem(StateObject stateObject) Adds the givenStateObjectas a select item.addSelectItem(StateObject stateObject, String resultVariable) Adds the givenStateObjectas a select item.addSelectItemAs(String jpqlFragment, String resultVariable) Adds the given expression as a select item.addSelectItemAs(StateObject stateObject, String resultVariable) Adds the givenStateObjectas a select item.protected AbstractFromClauseStateObjectCreates the state object representing theFROMclause.protected AbstractSelectClauseStateObjectCreates the state object representing theSELECTclause.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns the state object representing theFROMclause.Returns the state object representing theORDER BYclause.Returns the parent of thisStateObject.Creates and returns a newISelectExpressionStateObjectBuilderthat can be used to programmatically create a single select expression and once the expression is complete,ISelectExpressionStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this clause's select expression.Returns the state object representing theSELECTclause.booleanReturns the state object representing theORDER BYclause.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.voidRemoves theORDER BYclause.voidsetExpression(SelectStatement expression) Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.voidEither adds or removes theORDER BYclause.protected voidtoTextInternal(Appendable writer) Prints out a string representation of thisStateObject, which should not be used to define atruestring 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, toggleWhereClauseMethods 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 BYclause 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:StateObjectVisits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addChildren
Description copied from class:AbstractStateObjectAdds the children of thisStateObjectto the given list.- Overrides:
addChildrenin classAbstractSelectStatementStateObject- Parameters:
children- The list used to store the children
-
addOrderByClause
Adds theORDER BYclause. The clause is not added if it's already present.- Returns:
- The state object representing the
ORDER BYclause
-
addOrderByClause
Adds theORDER BYclause 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 givenStateObjectas a select item.- Parameters:
stateObject- TheStateObjectrepresenting a select expression
-
addSelectItem
Adds the givenStateObjectas a select item.- Parameters:
stateObject- TheStateObjectrepresenting 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
StateObjectencapsulating 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 givenStateObjectas a select item.- Parameters:
stateObject- TheStateObjectrepresenting 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:AbstractSelectStatementStateObjectCreates the state object representing theFROMclause.- Specified by:
buildFromClausein classAbstractSelectStatementStateObject- Returns:
- A concrete instance of
AbstractFromClauseStateObject
-
buildSelectClause
Description copied from class:AbstractSelectStatementStateObjectCreates the state object representing theSELECTclause.- Specified by:
buildSelectClausein classAbstractSelectStatementStateObject- Returns:
- A concrete instance of
AbstractSelectClauseStateObject
-
getExpression
Description copied from interface:StateObjectReturns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractSelectStatementStateObject- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObjectornullwhen the JPQL query is manually created (i.e. not from a string)
-
getFromClause
Description copied from class:AbstractSelectStatementStateObjectReturns the state object representing theFROMclause.- Overrides:
getFromClausein classAbstractSelectStatementStateObject- Returns:
- The state object representing the
FROMclause, which is nevernull
-
getOrderByClause
Returns the state object representing theORDER BYclause.- Returns:
- Either the actual state object representing the
ORDER BYclause ornullif it's not present
-
getParent
Description copied from interface:StateObjectReturns the parent of thisStateObject.- Specified by:
getParentin interfaceStateObject- Overrides:
getParentin classAbstractStateObject- Returns:
- Returns the parent of this
StateObject, which isnullonly when this is the root of the hierarchy
-
getSelectBuilder
Creates and returns a newISelectExpressionStateObjectBuilderthat can be used to programmatically create a single select expression and once the expression is complete,ISelectExpressionStateObjectBuilder.commit()will push theStateObjectrepresentation 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:AbstractSelectStatementStateObjectReturns the state object representing theSELECTclause.- Overrides:
getSelectClausein classAbstractSelectStatementStateObject- Returns:
- Either the actual state object representing the
SELECTclause, which is nevernull
-
hasOrderByClause
public boolean hasOrderByClause()Returns the state object representing theORDER BYclause.- Returns:
trueif theORDER BYclause is present;falseotherwise
-
isEquivalent
Description copied from interface:StateObjectDetermines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractSelectStatementStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
removeOrderByClause
public void removeOrderByClause()Removes theORDER BYclause. -
setExpression
Keeps a reference of theparsed objectobject, which should only be done when this object is instantiated during the conversion of a parsed JPQL query intoStateObjects.- Parameters:
expression- Theparsed objectrepresenting aSELECTstatement
-
toggleOrderByClause
public void toggleOrderByClause()Either adds or removes theORDER BYclause. -
toTextInternal
Description copied from class:AbstractStateObjectPrints out a string representation of thisStateObject, which should not be used to define atruestring representation of a JPQL query but should be used for debugging purposes.- Overrides:
toTextInternalin classAbstractSelectStatementStateObject- Parameters:
writer- The writer used to print out the string representation- Throws:
IOException- This should never happens, it is only required becauseAppendableis used instead of any concrete class
-