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
public abstract class AbstractSelectStatementStateObject extends AbstractStateObject
This state object represents the select statement, which has at least aSELECTclause and aFROMclause.- Since:
- 2.4
- Version:
- 2.5
- Author:
- Pascal Filion
- See Also:
SelectStatementStateObject,FromClauseStateObject,GroupByClauseStateObject,HavingClauseStateObject,SelectClauseStateObject,WhereClauseStateObject,AbstractSelectStatement
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUP_BY_CLAUSE_PROPERTYNotify the state object representing theGROUP BYclause has changed.static StringHAVING_CLAUSE_PROPERTYNotify the state object representing theHAVINGclause has changed.static StringWHERE_CLAUSE_PROPERTYNotify the state object representing theWHEREclause has changed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CollectionMemberDeclarationStateObjectaddCollectionDeclaration()Adds a new collection declaration to theFROMclause.CollectionMemberDeclarationStateObjectaddCollectionDeclaration(String collectionValuedPath, String identificationVariable)Adds a new collection declaration to theFROMclause.GroupByClauseStateObjectaddGroupByClause()Adds theGROUP BYclause.GroupByClauseStateObjectaddGroupByClause(String jpqlFragment)Adds theGROUP BYclause and parses the given JPQL fragment.HavingClauseStateObjectaddHavingClause()Adds theHAVINGclause.HavingClauseStateObjectaddHavingClause(String jpqlFragment)Adds theHAVINGclause and parses the given JPQL fragment.IdentificationVariableDeclarationStateObjectaddRangeDeclaration()Adds a new range variable declaration to theFROMclause.IdentificationVariableDeclarationStateObjectaddRangeDeclaration(String entityName, String identificationVariable)Adds to this select statement a new range variable declaration.IdentificationVariableDeclarationStateObjectaddRangeDeclaration(IEntity entity, String identificationVariable)Adds to this select statement a new range variable declaration.WhereClauseStateObjectaddWhereClause()Adds theWHEREclause.WhereClauseStateObjectaddWhereClause(String jpqlFragment)Adds theWHEREclause and parses the given JPQL fragment.ListIterable<? extends VariableDeclarationStateObject>declarations()Returns the list ofVariableDeclarationStateObjectdefining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.IdentificationVariableStateObjectfindIdentificationVariable(String identificationVariable)Returns theIdentificationVariableStateObjectrepresenting the given identification variable.DeclarationStateObjectgetDeclaration()Returns the declaration clause which defines the domain of the query by declaring identification variables.AbstractSelectStatementgetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.AbstractFromClauseStateObjectgetFromClause()Returns the state object representing theFROMclause.GroupByClauseStateObjectgetGroupByClause()Returns the state object representing theGROUP BYclause.HavingClauseStateObjectgetHavingClause()Returns the state object representing theHAVINGclause.AbstractSelectClauseStateObjectgetSelectClause()Returns the state object representing theSELECTclause.WhereClauseStateObjectgetWhereClause()Returns the state object representing theWHEREclause.booleanhasGroupByClause()Returns the state object representing theGROUP BYclause.booleanhasHavingClause()Returns the state object representing theHAVINGclause.booleanhasWhereClause()Returns the state object representing theWHEREclause.Iterable<IdentificationVariableStateObject>identificationVariables()Returns theIdentificationVariableStateObjectsholding onto the identification variables, which are the variables defined in theFROMclause.booleanisEquivalent(StateObject stateObject)Determines whether the givenStateObjectis equivalent to this one, i.e.voidparseSelect(String jpqlFragment)Parses the given JPQL fragment and create the select item.voidremoveGroupByClause()Removes theGROUP BYclause.voidremoveHavingClause()Removes theHAVINGclause.voidremoveWhereClause()Removes theWHEREclause.voidtoggleGroupByClause()Either adds or removes the state object representing theGROUP BYclause.voidtoggleHavingClause()Either adds or removes the state object representing theHAVINGclause.voidtoggleWhereClause()Either adds or removes the state object representing theWHEREclause.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
addPropertyChangeListener, children, decorate, equals, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, removePropertyChangeListener, setExpression, setParent, toString, toString, toText
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept
-
-
-
-
Field Detail
-
GROUP_BY_CLAUSE_PROPERTY
public static String GROUP_BY_CLAUSE_PROPERTY
Notify the state object representing theGROUP BYclause has changed.
-
HAVING_CLAUSE_PROPERTY
public static String HAVING_CLAUSE_PROPERTY
Notify the state object representing theHAVINGclause has changed.
-
WHERE_CLAUSE_PROPERTY
public static String WHERE_CLAUSE_PROPERTY
Notify the state object representing theWHEREclause has changed.
-
-
Method Detail
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration()
Adds a new collection declaration to theFROMclause.- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addCollectionDeclaration
public CollectionMemberDeclarationStateObject addCollectionDeclaration(String collectionValuedPath, String identificationVariable)
Adds a new collection declaration to theFROMclause.- Parameters:
collectionValuedPath- The collection-valued path expressionidentificationVariable- The variable defining the collection-valued path expression- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addGroupByClause
public GroupByClauseStateObject addGroupByClause()
Adds theGROUP BYclause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addGroupByClause
public GroupByClauseStateObject addGroupByClause(String jpqlFragment)
Adds theGROUP BYclause 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
public HavingClauseStateObject addHavingClause()
Adds theHAVINGclause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addHavingClause
public HavingClauseStateObject addHavingClause(String jpqlFragment)
Adds theHAVINGclause 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
public IdentificationVariableDeclarationStateObject addRangeDeclaration()
Adds a new range variable declaration to theFROMclause.- Returns:
- The
StateObjectrepresenting 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
StateObjectrepresenting 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
StateObjectrepresenting the range variable declaration
-
addWhereClause
public WhereClauseStateObject addWhereClause()
Adds theWHEREclause. The clause is not added if it's already present.- Returns:
- The
GroupByClauseStateObject
-
addWhereClause
public WhereClauseStateObject addWhereClause(String jpqlFragment)
Adds theWHEREclause 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
-
declarations
public ListIterable<? extends VariableDeclarationStateObject> declarations()
Returns the list ofVariableDeclarationStateObjectdefining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.Example:
Employee eIN (e.employees) AS emps
- Returns:
- The list of
VariableDeclarationStateObject
-
findIdentificationVariable
public IdentificationVariableStateObject findIdentificationVariable(String identificationVariable)
Returns theIdentificationVariableStateObjectrepresenting the given identification variable.- Specified by:
findIdentificationVariablein interfaceStateObject- Overrides:
findIdentificationVariablein classAbstractStateObject- Parameters:
identificationVariable- The name of the identification variable to retrieve its state object- Returns:
- The
IdentificationVariableStateObjectdefining the given identification variable
-
getDeclaration
public DeclarationStateObject getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring identification variables.- Specified by:
getDeclarationin interfaceStateObject- Overrides:
getDeclarationin classAbstractStateObject- Returns:
- The declaration clause of which this
StateObjectis 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
public AbstractSelectStatement getExpression()
Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpressionin interfaceStateObject- Overrides:
getExpressionin classAbstractStateObject- 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
public AbstractFromClauseStateObject getFromClause()
Returns the state object representing theFROMclause.- Returns:
- The state object representing the
FROMclause, which is nevernull
-
getGroupByClause
public GroupByClauseStateObject getGroupByClause()
Returns the state object representing theGROUP BYclause.- Returns:
- Either the actual state object representing the
GROUP BYclause ornullif it's not present
-
getHavingClause
public HavingClauseStateObject getHavingClause()
Returns the state object representing theHAVINGclause.- Returns:
- Either the actual state object representing the
HAVINGclause ornullif it's not present
-
getSelectClause
public AbstractSelectClauseStateObject getSelectClause()
Returns the state object representing theSELECTclause.- Returns:
- Either the actual state object representing the
SELECTclause, which is nevernull
-
getWhereClause
public WhereClauseStateObject getWhereClause()
Returns the state object representing theWHEREclause.- Returns:
- Either the actual state object representing the
WHEREclause or thenullstate object sincenullis never returned
-
hasGroupByClause
public boolean hasGroupByClause()
Returns the state object representing theGROUP BYclause.- Returns:
- Either the actual state object representing the
GROUP BYclause ornullif it's not present
-
hasHavingClause
public boolean hasHavingClause()
Returns the state object representing theHAVINGclause.- Returns:
- Either the actual state object representing the
HAVINGclause ornullif it's not present
-
hasWhereClause
public boolean hasWhereClause()
Returns the state object representing theWHEREclause.- Returns:
- Either the actual state object representing the
WHEREclause ornullif it's not present
-
identificationVariables
public Iterable<IdentificationVariableStateObject> identificationVariables()
Returns theIdentificationVariableStateObjectsholding onto the identification variables, which are the variables defined in theFROMclause.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
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObjectis equivalent to this one, i.e. the information of bothStateObjectis the same.- Specified by:
isEquivalentin interfaceStateObject- Overrides:
isEquivalentin classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
parseSelect
public void parseSelect(String jpqlFragment)
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 BYclause.
-
removeHavingClause
public void removeHavingClause()
Removes theHAVINGclause.
-
removeWhereClause
public void removeWhereClause()
Removes theWHEREclause.
-
toggleGroupByClause
public void toggleGroupByClause()
Either adds or removes the state object representing theGROUP BYclause.
-
toggleHavingClause
public void toggleHavingClause()
Either adds or removes the state object representing theHAVINGclause.
-
toggleWhereClause
public void toggleWhereClause()
Either adds or removes the state object representing theWHEREclause.
-
-