Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public abstract Class AbstractSelectStatementStateObject

extends AbstractStateObject
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.tools.model.query.SelectStatementStateObject, org.eclipse.persistence.jpa.jpql.tools.model.query.SimpleSelectStatementStateObject
Annotations
@SuppressWarnings:nls
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.parser.AbstractSelectStatement, org.eclipse.persistence.jpa.jpql.tools.spi.IEntity, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable

This state object represents the select statement, which has at least a SELECT clause and a FROM clause.
Author
Pascal Filion
Since
2.4
Version
2.5
See Also
SelectStatementStateObject, FromClauseStateObject, GroupByClauseStateObject, HavingClauseStateObject, SelectClauseStateObject, WhereClauseStateObject, AbstractSelectStatement

Field Summary

Modifier and TypeField and Description
private AbstractFromClauseStateObject
fromClause

The state object representing the FROM clause.

public static final String
GROUP_BY_CLAUSE_PROPERTY

Notify the state object representing the GROUP BY clause has changed.

private GroupByClauseStateObject
groupByClause

The state object representing the GROUP BY clause.

public static final String
HAVING_CLAUSE_PROPERTY

Notify the state object representing the HAVING clause has changed.

private HavingClauseStateObject
havingClause

The state object representing the HAVING clause.

private AbstractSelectClauseStateObject
selectClause

The state object representing the SELECT clause.

public static final String
WHERE_CLAUSE_PROPERTY

Notify the state object representing the WHERE clause has changed.

private WhereClauseStateObject
whereClause

The state object representing the WHERE clause.

Constructor Summary

AccessConstructor and Description
protected
AbstractSelectStatementStateObject(StateObject
The parent of this state object, which cannot be null
parent
)

Creates a new AbstractSelectStatementStateObject.

Method Summary

Modifier and TypeMethod and Description
protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.
public CollectionMemberDeclarationStateObject

Returns:

The CollectionMemberDeclarationStateObject representing the collection declaration
addCollectionDeclaration
()

Adds a new collection declaration to the FROM clause.

public CollectionMemberDeclarationStateObject

Returns:

The CollectionMemberDeclarationStateObject representing the collection declaration
addCollectionDeclaration
(String
The collection-valued path expression
collectionValuedPath
,
String
The variable defining the collection-valued path expression
identificationVariable
)

Adds a new collection declaration to the FROM clause.

public GroupByClauseStateObject
addGroupByClause()

Adds the GROUP BY clause.

public GroupByClauseStateObject
addGroupByClause(String
The fragment of the JPQL to parse that represents the group by items, the fragment cannot start with GROUP BY
jpqlFragment
)

Adds the GROUP BY clause and parses the given JPQL fragment.

public HavingClauseStateObject
addHavingClause()

Adds the HAVING clause.

public HavingClauseStateObject
addHavingClause(String
The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with HAVING
jpqlFragment
)

Adds the HAVING clause and parses the given JPQL fragment.

public IdentificationVariableDeclarationStateObject

Returns:

The StateObject representing the new range variable declaration
addRangeDeclaration
()

Adds a new range variable declaration to the FROM clause.

public IdentificationVariableDeclarationStateObject

Returns:

The StateObject representing the new range variable declaration
addRangeDeclaration
(IEntity
The external form of the entity to add to the declaration list
entity
,
String
The unique identifier identifying the given IEntity
identificationVariable
)

Adds to this select statement a new range variable declaration.

public IdentificationVariableDeclarationStateObject

Returns:

The StateObject representing the range variable declaration
addRangeDeclaration
(String
The name of the entity
entityName
,
String
The unique identifier identifying the entity
identificationVariable
)

Adds to this select statement a new range variable declaration.

public WhereClauseStateObject
addWhereClause()

Adds the WHERE clause.

public WhereClauseStateObject
addWhereClause(String
The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with WHERE
jpqlFragment
)

Adds the WHERE clause and parses the given JPQL fragment.

protected abstract AbstractFromClauseStateObject

Returns:

A concrete instance of AbstractFromClauseStateObject
buildFromClause
()

Creates the state object representing the FROM clause.

protected abstract AbstractSelectClauseStateObject

Returns:

A concrete instance of AbstractSelectClauseStateObject
buildSelectClause
()

Creates the state object representing the SELECT clause.

public ListIterable<? extends VariableDeclarationStateObject>

Returns:

The list of VariableDeclarationStateObject
declarations
()

Returns the list of VariableDeclarationStateObject defining the variable declarations, which are mapping an entity to a variable or a collection-valued member to a variable.

public IdentificationVariableStateObject
findIdentificationVariable(String
The name of the identification variable to retrieve its state object
identificationVariable
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.findIdentificationVariable.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.findIdentificationVariable.

Returns the IdentificationVariableStateObject representing the given identification variable.
public DeclarationStateObject
getDeclaration()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getDeclaration.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getDeclaration.

Returns the declaration clause which defines the domain of the query by declaring identification variables.
public AbstractSelectStatement
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
public AbstractFromClauseStateObject

Returns:

The state object representing the FROM clause, which is never null
getFromClause
()

Returns the state object representing the FROM clause.

public GroupByClauseStateObject

Returns:

Either the actual state object representing the GROUP BY clause or null if it's not present
getGroupByClause
()

Returns the state object representing the GROUP BY clause.

public HavingClauseStateObject

Returns:

Either the actual state object representing the HAVING clause or null if it's not present
getHavingClause
()

Returns the state object representing the HAVING clause.

public AbstractSelectClauseStateObject

Returns:

Either the actual state object representing the SELECT clause, which is never null
getSelectClause
()

Returns the state object representing the SELECT clause.

public WhereClauseStateObject

Returns:

Either the actual state object representing the WHERE clause or the null state object since null is never returned
getWhereClause
()

Returns the state object representing the WHERE clause.

public boolean

Returns:

Either the actual state object representing the GROUP BY clause or null if it's not present
hasGroupByClause
()

Returns the state object representing the GROUP BY clause.

public boolean

Returns:

Either the actual state object representing the HAVING clause or null if it's not present
hasHavingClause
()

Returns the state object representing the HAVING clause.

public boolean

Returns:

Either the actual state object representing the WHERE clause or null if it's not present
hasWhereClause
()

Returns the state object representing the WHERE clause.

public Iterable<IdentificationVariableStateObject>
identificationVariables()

Returns the IdentificationVariableStateObjects holding onto the identification variables, which are the variables defined in the FROM clause.

protected void
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
public void
parseSelect(String
The portion of the query representing one or several select items
jpqlFragment
)

Parses the given JPQL fragment and create the select item.

public void
removeGroupByClause()

Removes the GROUP BY clause.

public void
removeHavingClause()

Removes the HAVING clause.

public void
removeWhereClause()

Removes the WHERE clause.

private void
private void
private void
public void
toggleGroupByClause()

Either adds or removes the state object representing the GROUP BY clause.

public void
toggleHavingClause()

Either adds or removes the state object representing the HAVING clause.

public void
toggleWhereClause()

Either adds or removes the state object representing the WHERE clause.

protected void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfirePropertyChangedgetChangeSupportgetDecoratorgetGrammargetManagedTypeProvidergetParentgetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

fromClauseback to summary
private AbstractFromClauseStateObject fromClause

The state object representing the FROM clause.

GROUP_BY_CLAUSE_PROPERTYback to summary
public static final String GROUP_BY_CLAUSE_PROPERTY

Notify the state object representing the GROUP BY clause has changed.

groupByClauseback to summary
private GroupByClauseStateObject groupByClause

The state object representing the GROUP BY clause.

HAVING_CLAUSE_PROPERTYback to summary
public static final String HAVING_CLAUSE_PROPERTY

Notify the state object representing the HAVING clause has changed.

havingClauseback to summary
private HavingClauseStateObject havingClause

The state object representing the HAVING clause.

selectClauseback to summary
private AbstractSelectClauseStateObject selectClause

The state object representing the SELECT clause.

WHERE_CLAUSE_PROPERTYback to summary
public static final String WHERE_CLAUSE_PROPERTY

Notify the state object representing the WHERE clause has changed.

whereClauseback to summary
private WhereClauseStateObject whereClause

The state object representing the WHERE clause.

Constructor Detail

AbstractSelectStatementStateObjectback to summary
protected AbstractSelectStatementStateObject(StateObject parent)

Creates a new AbstractSelectStatementStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null

Method Detail

addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
addCollectionDeclarationback to summary
public CollectionMemberDeclarationStateObject addCollectionDeclaration()

Adds a new collection declaration to the FROM clause.

Returns:CollectionMemberDeclarationStateObject

The CollectionMemberDeclarationStateObject representing the collection declaration

addCollectionDeclarationback to summary
public CollectionMemberDeclarationStateObject addCollectionDeclaration(String collectionValuedPath, String identificationVariable)

Adds a new collection declaration to the FROM clause.

Parameters
collectionValuedPath:String

The collection-valued path expression

identificationVariable:String

The variable defining the collection-valued path expression

Returns:CollectionMemberDeclarationStateObject

The CollectionMemberDeclarationStateObject representing the collection declaration

addGroupByClauseback to summary
public GroupByClauseStateObject addGroupByClause()

Adds the GROUP BY clause. The clause is not added if it's already present.

Returns:GroupByClauseStateObject

The GroupByClauseStateObject

addGroupByClauseback to summary
public GroupByClauseStateObject addGroupByClause(String jpqlFragment)

Adds the GROUP BY clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters
jpqlFragment:String

The fragment of the JPQL to parse that represents the group by items, the fragment cannot start with GROUP BY

Returns:GroupByClauseStateObject

The GroupByClauseStateObject

addHavingClauseback to summary
public HavingClauseStateObject addHavingClause()

Adds the HAVING clause. The clause is not added if it's already present.

Returns:HavingClauseStateObject

The GroupByClauseStateObject

addHavingClauseback to summary
public HavingClauseStateObject addHavingClause(String jpqlFragment)

Adds the HAVING clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters
jpqlFragment:String

The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with HAVING

Returns:HavingClauseStateObject

The HavingClauseStateObject

addRangeDeclarationback to summary
public IdentificationVariableDeclarationStateObject addRangeDeclaration()

Adds a new range variable declaration to the FROM clause.

Returns:IdentificationVariableDeclarationStateObject

The StateObject representing the new range variable declaration

addRangeDeclarationback to summary
public IdentificationVariableDeclarationStateObject addRangeDeclaration(IEntity entity, String identificationVariable)

Adds to this select statement a new range variable declaration.

Parameters
entity:IEntity

The external form of the entity to add to the declaration list

identificationVariable:String

The unique identifier identifying the given IEntity

Returns:IdentificationVariableDeclarationStateObject

The StateObject representing the new range variable declaration

addRangeDeclarationback to summary
public IdentificationVariableDeclarationStateObject addRangeDeclaration(String entityName, String identificationVariable)

Adds to this select statement a new range variable declaration.

Parameters
entityName:String

The name of the entity

identificationVariable:String

The unique identifier identifying the entity

Returns:IdentificationVariableDeclarationStateObject

The StateObject representing the range variable declaration

addWhereClauseback to summary
public WhereClauseStateObject addWhereClause()

Adds the WHERE clause. The clause is not added if it's already present.

Returns:WhereClauseStateObject

The GroupByClauseStateObject

addWhereClauseback to summary
public WhereClauseStateObject addWhereClause(String jpqlFragment)

Adds the WHERE clause and parses the given JPQL fragment. The clause is not added if it's already present.

Parameters
jpqlFragment:String

The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with WHERE

Returns:WhereClauseStateObject

The WhereClauseStateObject

buildFromClauseback to summary
protected abstract AbstractFromClauseStateObject buildFromClause()

Creates the state object representing the FROM clause.

Returns:AbstractFromClauseStateObject

A concrete instance of AbstractFromClauseStateObject

buildSelectClauseback to summary
protected abstract AbstractSelectClauseStateObject buildSelectClause()

Creates the state object representing the SELECT clause.

Returns:AbstractSelectClauseStateObject

A concrete instance of AbstractSelectClauseStateObject

declarationsback to summary
public ListIterable<? extends VariableDeclarationStateObject> declarations()

Returns the list of VariableDeclarationStateObject 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:ListIterable<? extends VariableDeclarationStateObject>

The list of VariableDeclarationStateObject

findIdentificationVariableback to summary
public IdentificationVariableStateObject findIdentificationVariable(String identificationVariable)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.findIdentificationVariable.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.findIdentificationVariable.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.findIdentificationVariable.

Returns the IdentificationVariableStateObject representing the given identification variable.

Parameters
identificationVariable:String

The name of the identification variable to retrieve its state object

Returns:IdentificationVariableStateObject

The IdentificationVariableStateObject defining the given identification variable

Annotations
@Override
getDeclarationback to summary
public DeclarationStateObject getDeclaration()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getDeclaration.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getDeclaration.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getDeclaration.

Returns the declaration clause which defines the domain of the query by declaring identification variables.

Returns:DeclarationStateObject

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

Annotations
@Override
getExpressionback to summary
public AbstractSelectStatement getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:AbstractSelectStatement

The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

Annotations
@Override
getFromClauseback to summary
public AbstractFromClauseStateObject getFromClause()

Returns the state object representing the FROM clause.

Returns:AbstractFromClauseStateObject

The state object representing the FROM clause, which is never null

getGroupByClauseback to summary
public GroupByClauseStateObject getGroupByClause()

Returns the state object representing the GROUP BY clause.

Returns:GroupByClauseStateObject

Either the actual state object representing the GROUP BY clause or null if it's not present

getHavingClauseback to summary
public HavingClauseStateObject getHavingClause()

Returns the state object representing the HAVING clause.

Returns:HavingClauseStateObject

Either the actual state object representing the HAVING clause or null if it's not present

getSelectClauseback to summary
public AbstractSelectClauseStateObject getSelectClause()

Returns the state object representing the SELECT clause.

Returns:AbstractSelectClauseStateObject

Either the actual state object representing the SELECT clause, which is never null

getWhereClauseback to summary
public WhereClauseStateObject getWhereClause()

Returns the state object representing the WHERE clause.

Returns:WhereClauseStateObject

Either the actual state object representing the WHERE clause or the null state object since null is never returned

hasGroupByClauseback to summary
public boolean hasGroupByClause()

Returns the state object representing the GROUP BY clause.

Returns:boolean

Either the actual state object representing the GROUP BY clause or null if it's not present

hasHavingClauseback to summary
public boolean hasHavingClause()

Returns the state object representing the HAVING clause.

Returns:boolean

Either the actual state object representing the HAVING clause or null if it's not present

hasWhereClauseback to summary
public boolean hasWhereClause()

Returns the state object representing the WHERE clause.

Returns:boolean

Either the actual state object representing the WHERE clause or null if it's not present

identificationVariablesback to summary
public Iterable<IdentificationVariableStateObject> identificationVariables()

Returns the IdentificationVariableStateObjects holding onto the identification variables, which are the variables defined in the FROM clause.

Example:

  • Employee e; e is returned
  • IN (e.employees) AS emps; emps is returned
  • Manager m JOIN m.employees emps; m and emps are returned
Returns:Iterable<IdentificationVariableStateObject>

The list of IdentificationVariableStateObjects

initializeback to summary
protected void initialize()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.initialize.

Initializes this state object.

Annotations
@Override
isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
parseSelectback to summary
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:String

The portion of the query representing one or several select items

removeGroupByClauseback to summary
public void removeGroupByClause()

Removes the GROUP BY clause.

removeHavingClauseback to summary
public void removeHavingClause()

Removes the HAVING clause.

removeWhereClauseback to summary
public void removeWhereClause()

Removes the WHERE clause.

setGroupByClauseback to summary
private void setGroupByClause(GroupByClauseStateObject groupByClause)
setHavingClauseback to summary
private void setHavingClause(HavingClauseStateObject havingClause)
setWhereClauseback to summary
private void setWhereClause(WhereClauseStateObject whereClause)
toggleGroupByClauseback to summary
public void toggleGroupByClause()

Either adds or removes the state object representing the GROUP BY clause.

toggleHavingClauseback to summary
public void toggleHavingClause()

Either adds or removes the state object representing the HAVING clause.

toggleWhereClauseback to summary
public void toggleWhereClause()

Either adds or removes the state object representing the WHERE clause.

toTextInternalback to summary
protected void toTextInternal(Appendable writer) throws IOException

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.

Parameters
writer:Appendable

The writer used to print out the string representation

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class