Class JPQLQueryStateObject
java.lang.Object
org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
org.eclipse.persistence.jpa.jpql.tools.model.query.JPQLQueryStateObject
- All Implemented Interfaces:
StateObject
This is the root of the
StateObject hierarchy that represents a JPQL query. The only
child of this state object is one of the three possible query statements.- Since:
- 2.4
- Version:
- 2.4
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJPQLQueryStateObject(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider) Creates a newJPQLQueryStateObject. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(StateObjectVisitor visitor) Visits thisStateObjectby the givenvisitor.protected voidaddChildren(List<StateObject> children) Adds the children of thisStateObjectto the given list.Changes the query statement to be aDELETEstatement.Changes the query statement to be aSELECTstatement.Changes the query statement to be aSELECTstatement.addSelectStatement(String jpqlFragment) Changes the query statement to be aSELECTstatement.Changes the query statement to be aUPDATEstatement.addUpdateStatement(String jpqlFragment) Changes the query statement to be aUPDATEstatement.protected StateObjectcheckParent(StateObject parent) Checks whether the given parent isnullor not.Returns the declaration clause which defines the domain of the query by declaring identification variables.Returns the actual parsed object if thisStateObjectrepresentation of the JPQL query was created by parsing an existing JPQL query.Returns the grammar that defines how to parse a JPQL query.Returns the provider of managed types.Returns the parent of thisStateObject.Returns theIJPQLQueryBuilderthat is responsible to create various part of theStateObjecthierarchy.Returns the only child of this state object, which represents one of the three query statement.getRoot()Returns the root of theStateObjecthierarchy.booleanDetermines whether a query statement has been defined.protected voidinitialize(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider) Initializes thisJPQLQueryStateObject.booleanisEquivalent(StateObject stateObject) Determines whether the givenStateObjectis equivalent to this one, i.e.voidparse(CharSequence jpqlFragment, String queryBNFId) Parses the given JPQL fragment as this state object's query statement.voidsetExpression(JPQLExpression 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.voidsetQueryStatement(StateObject queryStatement) Sets the only child of this state object, which represents one of the three query statement.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.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDecorator, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
-
Field Details
-
QUERY_STATEMENT_PROPERTY
Notifies the query statement has changed.- See Also:
-
-
Constructor Details
-
JPQLQueryStateObject
Creates a newJPQLQueryStateObject.- Parameters:
queryBuilder- The builder that can create anyStateObjectfor any given JPQL fragment when using a parse methodprovider- The external form of a provider that gives access to the JPA metadata- Throws:
NullPointerException- If one of the given arguments isnull
-
-
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 classAbstractStateObject- Parameters:
children- The list used to store the children
-
addDeleteStatement
Changes the query statement to be aDELETEstatement.- Returns:
- The new root object of the
DELETEstatement
-
addDistinctSelectStatement
Changes the query statement to be aSELECTstatement. TheSELECTclause will have theDISTINCTidentifier set.- Returns:
- The new root object of the
SELECTstatement
-
addSelectStatement
Changes the query statement to be aSELECTstatement.- Returns:
- The new root object of the
SELECTstatement
-
addSelectStatement
Changes the query statement to be aSELECTstatement.- Parameters:
jpqlFragment- The portion of the query representing the select items, excluding theSELECTidentifier- Returns:
- The new root object of the
SELECTstatement
-
addUpdateStatement
Changes the query statement to be aUPDATEstatement.- Returns:
- The new root object of the
UPDTEstatement
-
addUpdateStatement
Changes the query statement to be aUPDATEstatement.- Parameters:
jpqlFragment- The portion of the query representing the select items, excluding theUPDATEidentifier- Returns:
- The new root object of the
UPDATEstatement
-
checkParent
Description copied from class:AbstractStateObject- Overrides:
checkParentin classAbstractStateObject- Parameters:
parent- The parent of this state object- Returns:
- The given object
-
getDeclaration
Description copied from interface:StateObjectReturns 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
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 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)
-
getGrammar
Description copied from interface:StateObjectReturns the grammar that defines how to parse a JPQL query.- Specified by:
getGrammarin interfaceStateObject- Overrides:
getGrammarin classAbstractStateObject- Returns:
- The grammar that was used to parse the JPQL query
-
getManagedTypeProvider
Description copied from interface:StateObjectReturns the provider of managed types.- Specified by:
getManagedTypeProviderin interfaceStateObject- Overrides:
getManagedTypeProviderin classAbstractStateObject- Returns:
- The provider that gives access to the managed types
-
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
-
getQueryBuilder
Description copied from interface:StateObjectReturns theIJPQLQueryBuilderthat is responsible to create various part of theStateObjecthierarchy.- Specified by:
getQueryBuilderin interfaceStateObject- Overrides:
getQueryBuilderin classAbstractStateObject- Returns:
- The builder that created this
StateObjectfrom a JPQL query or that gives access to various sub-builders
-
getQueryStatement
Returns the only child of this state object, which represents one of the three query statement.- Returns:
- The state object representing the query statement, which was created based on the query type
-
getRoot
Description copied from interface:StateObjectReturns the root of theStateObjecthierarchy.- Specified by:
getRootin interfaceStateObject- Overrides:
getRootin classAbstractStateObject- Returns:
- The root of the state model representing the JPQL query
-
hasQueryStatement
public boolean hasQueryStatement()Determines whether a query statement has been defined.- Returns:
trueif there is a query statement defined;falseotherwise
-
initialize
Initializes thisJPQLQueryStateObject.- Parameters:
queryBuilder- The builder that can create anyStateObjectfor any given JPQL fragmentprovider- The external form that gives access to the JPA metadata- Throws:
NullPointerException- If one of the given arguments isnull
-
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 classAbstractStateObject- Parameters:
stateObject- TheStateObjectto compare its content to this one- Returns:
trueif both object are equivalent;falseotherwise
-
parse
Parses the given JPQL fragment as this state object's query statement.- Parameters:
jpqlFragment- The portion of the query to parsequeryBNFId- The unique identifier of the BNF that determines how to parse the fragment
-
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 the JPQL query
-
setQueryStatement
Sets the only child of this state object, which represents one of the three query statement.- Parameters:
queryStatement- The state object representing the query statement, which was created based on the query type
-
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.- Specified by:
toTextInternalin classAbstractStateObject- 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
-