Class AbstractSelectStatementStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractSelectStatementStateObject
- All Implemented Interfaces:
StateObject
- Direct Known Subclasses:
SelectStatementStateObject
,SimpleSelectStatementStateObject
This state object represents the select statement, which has at least a
SELECT
clause and a FROM
clause.- Since:
- 2.4
- Version:
- 2.5
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Notify the state object representing theGROUP BY
clause has changed.static final String
Notify the state object representing theHAVING
clause has changed.static final String
Notify the state object representing theWHERE
clause has changed. -
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a newAbstractSelectStatementStateObject
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addChildren
(List<StateObject> children) Adds the children of thisStateObject
to the given list.Adds a new collection declaration to theFROM
clause.addCollectionDeclaration
(String collectionValuedPath, String identificationVariable) Adds a new collection declaration to theFROM
clause.Adds theGROUP BY
clause.addGroupByClause
(String jpqlFragment) Adds theGROUP BY
clause and parses the given JPQL fragment.Adds theHAVING
clause.addHavingClause
(String jpqlFragment) Adds theHAVING
clause and parses the given JPQL fragment.Adds a new range variable declaration to theFROM
clause.addRangeDeclaration
(String entityName, String identificationVariable) Adds to this select statement a new range variable declaration.addRangeDeclaration
(IEntity entity, String identificationVariable) Adds to this select statement a new range variable declaration.Adds theWHERE
clause.addWhereClause
(String jpqlFragment) Adds theWHERE
clause and parses the given JPQL fragment.protected abstract AbstractFromClauseStateObject
Creates the state object representing theFROM
clause.protected abstract AbstractSelectClauseStateObject
Creates the state object representing theSELECT
clause.ListIterable
<? extends VariableDeclarationStateObject> Returns the list ofVariableDeclarationStateObject
defining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.findIdentificationVariable
(String identificationVariable) Returns theIdentificationVariableStateObject
representing the given identification variable.Returns the declaration clause which defines the domain of the query by declaring identification variables.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 theGROUP BY
clause.Returns the state object representing theHAVING
clause.Returns the state object representing theSELECT
clause.Returns the state object representing theWHERE
clause.boolean
Returns the state object representing theGROUP BY
clause.boolean
Returns the state object representing theHAVING
clause.boolean
Returns the state object representing theWHERE
clause.Returns theIdentificationVariableStateObjects
holding onto the identification variables, which are the variables defined in theFROM
clause.protected void
Initializes this state object.boolean
isEquivalent
(StateObject stateObject) Determines whether the givenStateObject
is equivalent to this one, i.e.void
parseSelect
(String jpqlFragment) Parses the given JPQL fragment and create the select item.void
Removes theGROUP BY
clause.void
Removes theHAVING
clause.void
Removes theWHERE
clause.void
Either adds or removes the state object representing theGROUP BY
clause.void
Either adds or removes the state object representing theHAVING
clause.void
Either adds or removes the state object representing theWHERE
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.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, firePropertyChanged, getChangeSupport, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept
-
Field Details
-
GROUP_BY_CLAUSE_PROPERTY
Notify the state object representing theGROUP BY
clause has changed.- See Also:
-
HAVING_CLAUSE_PROPERTY
Notify the state object representing theHAVING
clause has changed.- See Also:
-
WHERE_CLAUSE_PROPERTY
Notify the state object representing theWHERE
clause has changed.- See Also:
-
-
Constructor Details
-
AbstractSelectStatementStateObject
Creates a newAbstractSelectStatementStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
NullPointerException
- The given parent cannot benull
-
-
Method Details
-
addChildren
Description copied from class:AbstractStateObject
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractStateObject
- Parameters:
children
- The list used to store the children
-
addCollectionDeclaration
Adds a new collection declaration to theFROM
clause.- Returns:
- The
CollectionMemberDeclarationStateObject
representing the collection declaration
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration(String collectionValuedPath, String identificationVariable) Adds a new collection declaration to theFROM
clause.- Parameters:
collectionValuedPath
- The collection-valued path expressionidentificationVariable
- The variable defining the collection-valued path expression- Returns:
- The
CollectionMemberDeclarationStateObject
representing the collection declaration
-
addGroupByClause
Adds theGROUP BY
clause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addGroupByClause
Adds theGROUP BY
clause and parses the given JPQL fragment. The clause is not added if it's already present.- Parameters:
jpqlFragment
- The fragment of the JPQL to parse that represents the group by items, the fragment cannot start withGROUP BY
- Returns:
- The
GroupByClauseStateObject
-
addHavingClause
Adds theHAVING
clause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addHavingClause
Adds theHAVING
clause and parses the given JPQL fragment. The clause is not added if it's already present.- Parameters:
jpqlFragment
- The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start withHAVING
- Returns:
- The
HavingClauseStateObject
-
addRangeDeclaration
Adds a new range variable declaration to theFROM
clause.- Returns:
- The
StateObject
representing the new range variable declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity, String identificationVariable) Adds to this select statement a new range variable declaration.- Parameters:
entity
- The external form of the entity to add to the declaration listidentificationVariable
- The unique identifier identifying the givenIEntity
- Returns:
- The
StateObject
representing the new range variable declaration
-
addRangeDeclaration
public IdentificationVariableDeclarationStateObject addRangeDeclaration(String entityName, String identificationVariable) Adds to this select statement a new range variable declaration.- Parameters:
entityName
- The name of the entityidentificationVariable
- The unique identifier identifying the entity- Returns:
- The
StateObject
representing the range variable declaration
-
addWhereClause
Adds theWHERE
clause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addWhereClause
Adds theWHERE
clause and parses the given JPQL fragment. The clause is not added if it's already present.- Parameters:
jpqlFragment
- The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start withWHERE
- Returns:
- The
WhereClauseStateObject
-
buildFromClause
Creates the state object representing theFROM
clause.- Returns:
- A concrete instance of
AbstractFromClauseStateObject
-
buildSelectClause
Creates the state object representing theSELECT
clause.- Returns:
- A concrete instance of
AbstractSelectClauseStateObject
-
declarations
Returns the list ofVariableDeclarationStateObject
defining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.Example:
Employee e
IN (e.employees) AS emps
- Returns:
- The list of
VariableDeclarationStateObject
-
findIdentificationVariable
Description copied from interface:StateObject
Returns theIdentificationVariableStateObject
representing the given identification variable.- Specified by:
findIdentificationVariable
in interfaceStateObject
- Overrides:
findIdentificationVariable
in classAbstractStateObject
- Parameters:
identificationVariable
- The name of the identification variable to retrieve its state object- Returns:
- The
IdentificationVariableStateObject
defining the given identification variable
-
getDeclaration
Description copied from interface:StateObject
Returns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclaration
in interfaceStateObject
- Overrides:
getDeclaration
in classAbstractStateObject
- Returns:
- The declaration clause of which this
StateObject
is a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery
-
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 classAbstractStateObject
- 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
Returns the state object representing theFROM
clause.- Returns:
- The state object representing the
FROM
clause, which is nevernull
-
getGroupByClause
Returns the state object representing theGROUP BY
clause.- Returns:
- Either the actual state object representing the
GROUP BY
clause ornull
if it's not present
-
getHavingClause
Returns the state object representing theHAVING
clause.- Returns:
- Either the actual state object representing the
HAVING
clause ornull
if it's not present
-
getSelectClause
Returns the state object representing theSELECT
clause.- Returns:
- Either the actual state object representing the
SELECT
clause, which is nevernull
-
getWhereClause
Returns the state object representing theWHERE
clause.- Returns:
- Either the actual state object representing the
WHERE
clause or thenull
state object sincenull
is never returned
-
hasGroupByClause
public boolean hasGroupByClause()Returns the state object representing theGROUP BY
clause.- Returns:
- Either the actual state object representing the
GROUP BY
clause ornull
if it's not present
-
hasHavingClause
public boolean hasHavingClause()Returns the state object representing theHAVING
clause.- Returns:
- Either the actual state object representing the
HAVING
clause ornull
if it's not present
-
hasWhereClause
public boolean hasWhereClause()Returns the state object representing theWHERE
clause.- Returns:
- Either the actual state object representing the
WHERE
clause ornull
if it's not present
-
identificationVariables
Returns theIdentificationVariableStateObjects
holding onto the identification variables, which are the variables defined in theFROM
clause.Example:
Employee e
; e is returnedIN (e.employees) AS emps
; emps is returnedManager m JOIN m.employees emps
; m and emps are returned
- Returns:
- The list of
IdentificationVariableStateObjects
-
initialize
protected void initialize()Description copied from class:AbstractStateObject
Initializes this state object.- Overrides:
initialize
in classAbstractStateObject
-
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 classAbstractStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
parseSelect
Parses the given JPQL fragment and create the select item. For the top-level query, the fragment can contain several select items but for a subquery, it can represent only one.- Parameters:
jpqlFragment
- The portion of the query representing one or several select items
-
removeGroupByClause
public void removeGroupByClause()Removes theGROUP BY
clause. -
removeHavingClause
public void removeHavingClause()Removes theHAVING
clause. -
removeWhereClause
public void removeWhereClause()Removes theWHERE
clause. -
toggleGroupByClause
public void toggleGroupByClause()Either adds or removes the state object representing theGROUP BY
clause. -
toggleHavingClause
public void toggleHavingClause()Either adds or removes the state object representing theHAVING
clause. -
toggleWhereClause
public void toggleWhereClause()Either adds or removes the state object representing theWHERE
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.- Specified by:
toTextInternal
in classAbstractStateObject
- 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
-