public class JPQLQueryStateObject extends AbstractStateObject
StateObject
hierarchy that represents a JPQL query. The only
child of this state object is one of the three possible query statements.DeleteStatementStateObject
,
SelectStatementStateObject
,
UpdateStatementStateObject
,
JPQLExpression
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
QUERY_STATEMENT_PROPERTY
Notifies the query statement has changed.
|
Constructor and Description |
---|
JPQLQueryStateObject(IJPQLQueryBuilder queryBuilder,
IManagedTypeProvider provider)
Creates a new
JPQLQueryStateObject . |
Modifier and Type | Method and Description |
---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor . |
DeleteStatementStateObject |
addDeleteStatement()
Changes the query statement to be a
DELETE statement. |
SelectStatementStateObject |
addDistinctSelectStatement()
Changes the query statement to be a
SELECT statement. |
SelectStatementStateObject |
addSelectStatement()
Changes the query statement to be a
SELECT statement. |
SelectStatementStateObject |
addSelectStatement(java.lang.String jpqlFragment)
Changes the query statement to be a
SELECT statement. |
UpdateStatementStateObject |
addUpdateStatement()
Changes the query statement to be a
UPDATE statement. |
UpdateStatementStateObject |
addUpdateStatement(java.lang.String jpqlFragment)
Changes the query statement to be a
UPDATE statement. |
DeclarationStateObject |
getDeclaration()
Returns the declaration clause which defines the domain of the query by declaring
identification variables.
|
JPQLExpression |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
JPQLGrammar |
getGrammar()
Returns the grammar that defines how to parse a JPQL query.
|
IManagedTypeProvider |
getManagedTypeProvider()
Returns the provider of managed types.
|
StateObject |
getParent()
Returns the parent of this
StateObject . |
IJPQLQueryBuilder |
getQueryBuilder()
Returns the
IJPQLQueryBuilder that is responsible to create various part of the StateObject hierarchy. |
StateObject |
getQueryStatement()
Returns the only child of this state object, which represents one of the three query statement.
|
JPQLQueryStateObject |
getRoot()
Returns the root of the
StateObject hierarchy. |
boolean |
hasQueryStatement()
Determines whether a query statement has been defined.
|
boolean |
isEquivalent(StateObject stateObject)
Determines whether the given
StateObject is equivalent to this one, i.e. |
void |
parse(java.lang.CharSequence jpqlFragment,
java.lang.String queryBNFId)
Parses the given JPQL fragment as this state object's query statement.
|
void |
setExpression(JPQLExpression expression)
Keeps a reference of the
parsed object object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects . |
void |
setQueryStatement(StateObject queryStatement)
Sets the only child of this state object, which represents one of the three query statement.
|
addPropertyChangeListener, children, decorate, equals, findIdentificationVariable, getDecorator, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, removePropertyChangeListener, setExpression, setParent, toString, toString, toText
public static final java.lang.String QUERY_STATEMENT_PROPERTY
public JPQLQueryStateObject(IJPQLQueryBuilder queryBuilder, IManagedTypeProvider provider)
JPQLQueryStateObject
.queryBuilder
- The builder that can create any StateObject
for any given JPQL
fragment when using a parse methodprovider
- The external form of a provider that gives access to the JPA metadatajava.lang.NullPointerException
- If one of the given arguments is null
public void accept(StateObjectVisitor visitor)
StateObject
by the given visitor
.visitor
- The visitor
to visit this objectpublic DeleteStatementStateObject addDeleteStatement()
DELETE
statement.DELETE
statementpublic SelectStatementStateObject addDistinctSelectStatement()
SELECT
statement. The SELECT
clause will have the DISTINCT
identifier set.SELECT
statementpublic SelectStatementStateObject addSelectStatement()
SELECT
statement.SELECT
statementpublic SelectStatementStateObject addSelectStatement(java.lang.String jpqlFragment)
SELECT
statement.jpqlFragment
- The portion of the query representing the select items, excluding the
SELECT
identifierSELECT
statementpublic UpdateStatementStateObject addUpdateStatement()
UPDATE
statement.UPDTE
statementpublic UpdateStatementStateObject addUpdateStatement(java.lang.String jpqlFragment)
UPDATE
statement.jpqlFragment
- The portion of the query representing the select items, excluding the
UPDATE
identifierUPDATE
statementpublic DeclarationStateObject getDeclaration()
getDeclaration
in interface StateObject
getDeclaration
in class AbstractStateObject
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 subquerypublic JPQLExpression getExpression()
StateObject
representation of the JPQL query
was created by parsing an existing JPQL query.getExpression
in interface StateObject
getExpression
in class AbstractStateObject
StateObject
or null
when the JPQL query is manually created (i.e. not from a string)public JPQLGrammar getGrammar()
getGrammar
in interface StateObject
getGrammar
in class AbstractStateObject
public IManagedTypeProvider getManagedTypeProvider()
getManagedTypeProvider
in interface StateObject
getManagedTypeProvider
in class AbstractStateObject
public StateObject getParent()
StateObject
.getParent
in interface StateObject
getParent
in class AbstractStateObject
StateObject
, which is null
only when
this is the root of the hierarchypublic IJPQLQueryBuilder getQueryBuilder()
IJPQLQueryBuilder
that is responsible to create various part of the StateObject
hierarchy.getQueryBuilder
in interface StateObject
getQueryBuilder
in class AbstractStateObject
StateObject
from a JPQL query or that gives
access to various sub-builderspublic StateObject getQueryStatement()
public JPQLQueryStateObject getRoot()
StateObject
hierarchy.getRoot
in interface StateObject
getRoot
in class AbstractStateObject
public boolean hasQueryStatement()
true
if there is a query statement defined; false
otherwisepublic boolean isEquivalent(StateObject stateObject)
StateObject
is equivalent to this one, i.e. the
information of both StateObject
is the same.isEquivalent
in interface StateObject
isEquivalent
in class AbstractStateObject
stateObject
- The StateObject
to compare its content to this onetrue
if both object are equivalent; false
otherwisepublic void parse(java.lang.CharSequence jpqlFragment, java.lang.String queryBNFId)
jpqlFragment
- The portion of the query to parsequeryBNFId
- The unique identifier of the BNF that determines how to parse the fragmentpublic void setExpression(JPQLExpression expression)
parsed object
object, which should only be
done when this object is instantiated during the conversion of a parsed JPQL query into
StateObjects
.expression
- The parsed object
representing the JPQL querypublic void setQueryStatement(StateObject queryStatement)
queryStatement
- The state object representing the query statement, which was created
based on the query typeEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference