Class SimpleSelectStatementStateObject
- 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.SimpleSelectStatementStateObject
-
- All Implemented Interfaces:
StateObject
public class SimpleSelectStatementStateObject extends AbstractSelectStatementStateObject
This state object represents a subquery, which has at least aSELECTclause and aFROMclause. The other clauses are optional.BNF:
subquery ::= simple_select_clause subquery_from_clause [where_clause] [groupby_clause] [having_clause]- Since:
- 2.4
- Version:
- 2.4
- Author:
- Pascal Filion
- See Also:
SimpleSelectStatement
-
-
Field Summary
-
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
Constructors Constructor Description SimpleSelectStatementStateObject(StateObject parent)Creates a newSimpleSelectStatementStateObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(StateObjectVisitor visitor)Visits thisStateObjectby the givenvisitor.CollectionMemberDeclarationStateObjectaddDerivedCollectionDeclaration()Adds a new derived collection declaration to theFROMclause.CollectionMemberDeclarationStateObjectaddDerivedCollectionDeclaration(String collectionValuedPath)Adds a new derived collection declaration to theFROMclause.DerivedPathIdentificationVariableDeclarationStateObjectaddDerivedPathDeclaration()Adds a new derived identification variable declaration to theFROMclause.DerivedPathIdentificationVariableDeclarationStateObjectaddDerivedPathDeclaration(String path, String identificationVariable)Adds a new derived identification variable declaration to theFROMclause.SimpleSelectStatementgetExpression()Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.SimpleFromClauseStateObjectgetFromClause()Returns the state object representing theFROMclause.ISimpleSelectExpressionStateObjectBuildergetSelectBuilder()Creates and returns a newISimpleSelectExpressionStateObjectBuilderthat can be used to programmatically create a single select expression and once the expression is complete,ISimpleSelectExpressionStateObjectBuilder.commit()will push theStateObjectrepresentation of that expression as this clause's select expression.SimpleSelectClauseStateObjectgetSelectClause()Returns the state object representing theSELECTclause.voidsetExpression(SimpleSelectStatement 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.voidsetSelectItem(String jpqlFragment)Parses the given JPQL fragment and create the select item.voidsetSelectItem(StateObject stateObject)Sets the givenStateObjectas theSELECTclause's select item.-
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, isEquivalent, parseSelect, removeGroupByClause, removeHavingClause, removeWhereClause, toggleGroupByClause, toggleHavingClause, toggleWhereClause
-
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
-
-
-
-
Constructor Detail
-
SimpleSelectStatementStateObject
public SimpleSelectStatementStateObject(StateObject parent)
Creates a newSimpleSelectStatementStateObject.- Parameters:
parent- The parent of this state object, which cannot benull- Throws:
NullPointerException- The given parent cannot benull
-
-
Method Detail
-
accept
public void accept(StateObjectVisitor visitor)
Visits thisStateObjectby the givenvisitor.- Parameters:
visitor- Thevisitorto visit this object
-
addDerivedCollectionDeclaration
public CollectionMemberDeclarationStateObject addDerivedCollectionDeclaration()
Adds a new derived collection declaration to theFROMclause.- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addDerivedCollectionDeclaration
public CollectionMemberDeclarationStateObject addDerivedCollectionDeclaration(String collectionValuedPath)
Adds a new derived collection declaration to theFROMclause.- Parameters:
collectionValuedPath- The collection-valued path expression- Returns:
- The
CollectionMemberDeclarationStateObjectrepresenting the collection declaration
-
addDerivedPathDeclaration
public DerivedPathIdentificationVariableDeclarationStateObject addDerivedPathDeclaration()
Adds a new derived identification variable declaration to theFROMclause.- Returns:
- The
DerivedPathIdentificationVariableDeclarationStateObjectrepresenting the collection declaration
-
addDerivedPathDeclaration
public DerivedPathIdentificationVariableDeclarationStateObject addDerivedPathDeclaration(String path, String identificationVariable)
Adds a new derived identification variable declaration to theFROMclause.- Parameters:
path- Either the derived singled-valued object field or the collection-valued path expressionidentificationVariable- The identification variable defining the given path- Returns:
- The
DerivedPathIdentificationVariableDeclarationStateObjectrepresenting the path declaration
-
getExpression
public SimpleSelectStatement 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 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
public SimpleFromClauseStateObject getFromClause()
Returns the state object representing theFROMclause.- Overrides:
getFromClausein classAbstractSelectStatementStateObject- Returns:
- The state object representing the
FROMclause, which is nevernull
-
getSelectBuilder
public ISimpleSelectExpressionStateObjectBuilder getSelectBuilder()
Creates and returns a newISimpleSelectExpressionStateObjectBuilderthat can be used to programmatically create a single select expression and once the expression is complete,ISimpleSelectExpressionStateObjectBuilder.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
public SimpleSelectClauseStateObject getSelectClause()
Returns the state object representing theSELECTclause.- Overrides:
getSelectClausein classAbstractSelectStatementStateObject- Returns:
- Either the actual state object representing the
SELECTclause, which is nevernull
-
setExpression
public void setExpression(SimpleSelectStatement 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.- Parameters:
expression- Theparsed objectrepresenting a subquerySELECTstatement
-
setSelectItem
public void setSelectItem(StateObject stateObject)
Sets the givenStateObjectas theSELECTclause's select item.- Parameters:
stateObject- TheStateObjectrepresenting the single select item
-
setSelectItem
public void setSelectItem(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
-
-