IQuery externalQuery = ...;
JPQLQueryContext context = new JPQLQueryContext(DefaultJPQLGrammar.instance());
context.setQuery(query);
If the JPQL query is already parsed, then the context can use it and it needs to be set before
setting the IQuery:
JPQLExpression jpqlExpression = ...;
JPQLQueryContext context = new JPQLQueryContext(DefaultJPQLGrammar.instance());
context.setJPQLExpression(jpqlExpression);
context.setQuery(query);
Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.
| Modifier and Type | Class and Description |
|---|---|
| protected class | JPQLQueryContext.InputParameterVisitor
This visitor is responsible to find the |
| protected static class | JPQLQueryContext.QueryExpressionVisitor
This visitor is responsible to retrieve the |
| Modifier and Type | Field and Description |
|---|---|
| private Map | |
| protected JPQLQueryContext | currentContext
The current |
| private Expression | currentQuery
The parsed |
| private DeclarationResolver | declarationResolver
The resolver of the current query's declaration. |
| private JPQLQueryContext. | inputParameterVisitor
This visitor is responsible to find the |
| private JPQLExpression | jpqlExpression
The parsed tree representation of the JPQL query. |
| private JPQLGrammar | jpqlGrammar
The grammar that defines how to parse a JPQL query. |
| private LiteralVisitor | literalVisitor
This visitor is used to retrieve a variable name from various type of |
| private ParameterTypeVisitor | parameterTypeVisitor
This visitor is responsible to calculate the closest type of any input parameter. |
| protected JPQLQueryContext | parent
When this context is a sub-context used for a subquery, then this is the context for the parent query. |
| private IQuery | query
The external form of the JPQL query being manipulated. |
| private JPQLQueryContext. | queryExpressionVisitor
This visitor is responsible to retrieve the |
| private ResolverBuilder | resolverBuilder
This visitor creates a |
| private boolean | tolerant
Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries. |
| private boolean | traversed
Internal flag used to determine if the declaration portion of the query was visited. |
| Access | Constructor and Description |
|---|---|
| public | JPQLQueryContext(JPQLGrammar
The jpqlGrammar)JPQLGrammar defines how to parse a JPQL queryCreates a new |
| protected | JPQLQueryContext(JPQLQueryContext
The parent context parent, Expression The parsed tree representation of the subquery currentQuery)Creates a new sub- |
| Modifier and Type | Method and Description |
|---|---|
| protected DeclarationResolver | |
| protected DeclarationResolver | |
| protected JPQLQueryContext. | |
| protected abstract JPQLQueryContext | |
| protected abstract LiteralVisitor | |
| protected abstract ParameterTypeVisitor | |
| protected JPQLQueryContext. | |
| protected abstract ResolverBuilder | |
| public void | convertUnqualifiedDeclaration(Declaration
The declaration)Declaration that was parsed to range over an abstract schema
name but is actually ranging over a path expressionConverts the given |
| public void | |
| public void | disposeSubqueryContext()
Disposes this context, which is the current context being used by a subquery. |
| public Collection | Returns: Either theInputParameters that has the given parameter or an
empty collectionThe parameter used to find the parameterName)InputParameters
with the same valueRetrieves all the |
| public Expression | Returns: Either the top-level query or a subqueryReturns the current |
| public DeclarationResolver | Returns: TheDeclarationResolver for this contextReturns the |
| public JPQLQueryContext | Returns: The active contextReturns the current |
| public Expression | Returns: Either the top-level query or a subqueryReturns the current |
| public Declaration | Returns: TheDeclaration containing the information about the identification variable declarationThe name of the identification variable that is used to navigate a "root" object variableName)Retrieves the |
| public DeclarationResolver | Returns: TheDeclarationResolver for the current query being visitedReturns the |
| public DeclarationResolver | Returns: TheDeclarationResolver for the current query being visitedThe expression)Expression that will be used to retrieve its query expression,
i.e. either JPQLExpression or SimpleSelectStatementReturns the |
| protected DeclarationResolver | Returns: TheDeclarationResolver for the current query being visitedReturns the |
| public List | Returns: TheDeclarations of the current query that was parsedReturns the ordered list of |
| public IType | Returns: The external form for the given Enum typeThe fully qualified enum type with the constant enumTypeName)Returns the |
| public ExpressionRegistry | Returns: The registry containing the information related to the JPQL grammarReturns the registry containing the |
| public JPQLGrammar | Returns: The grammar that was used to parse thisExpressionReturns the JPQL grammar that will be used to define how to parse a JPQL query. |
| protected JPQLQueryContext. | |
| public JPAVersion | Returns: The version of the supported Java Persistence functional specificationReturns the version of the Java Persistence to support, which dictates which version of the JPQL grammar to support. |
| public JPQLExpression | Returns: The parsed tree representation of the JPQL queryReturns the parsed tree representation of the JPQL query. |
| public String | Returns: The string representation of the JPQL queryReturns the string representation of the JPQL query. |
| protected LiteralVisitor | |
| public IMapping | getMapping(Expression
The expression)Expression representing a state field path expression or a
collection-valued path expressionReturns the |
| public IType | Returns: Either the closest type of the input parameter ornull if the type could
not be determinedThe inputParameter)InputParameter to retrieve its typeRetrieves, if it can be determined, the type of the given |
| protected ParameterTypeVisitor | |
| public JPQLQueryContext | Returns: The parent context ornull if the current context is the rootReturns the parent context if the current context is not the root context. |
| public IManagedTypeProvider | Returns: The object that has access to the application's managed types.Retrieves the provider of managed types. |
| public String | Returns: The version of the persistence provider, if one is extending the default JPQL grammar defined in the Java Persistence specification, otherwise returns an empty stringReturns the version of the persistence provider. |
| public IQuery | |
| public Expression | Returns: The query statement that is the "root" parent of the givenExpressionA child of the "root" expression)Expression to retrieveRetrieves the |
| protected JPQLQueryContext. | |
| public Resolver | getResolver(Expression
The expression)Expression for which its Resolver will be retrievedCreates or retrieved the cached |
| public Resolver | Returns: TheResolver mapped with the given identification variableThe identification variable that maps a variableName)ResolverRetrieves the |
| protected ResolverBuilder | |
| public Set | Returns: The variables identifying the select expressions, if any was defined or an empty set if none were definedReturns the variables that got defined in the select expression. |
| public IType | |
| public IType | Returns: Either theIType that was resolved by this Resolver or the
IType for IType#UNRESOLVABLE_TYPE if it could not be resolvedThe expression)Expression for which its type will be calculatedReturns the |
| public IType | |
| public ITypeDeclaration | Returns: Either theITypeDeclaration that was resolved by this Resolver or the
ITypeDeclaration for IType#UNRESOLVABLE_TYPE if it could not be resolvedThe expression)Expression for which its type declaration will be calculatedReturns the |
| public TypeHelper | Returns: A helper containing a collection of methods related toITypeReturns a helper that gives access to the most common |
| public ITypeRepository | Returns: The repository ofITypesReturns the type repository for the application. |
| public boolean | Returns: true if the query or subquery being traversed contains JOIN
expressions; false otherwiseDetermines whether the JPQL expression has JOIN expressions. |
| protected void | initialize(JPQLGrammar
The grammar that defines how to parse a JPQL query jpqlGrammar)Initializes this |
| protected void | initializeRoot()
Initializes the parsed tree representation of the JPQL query if it has not been set before
setting the |
| public boolean | Returns: true if the given identification variable maps a collection-valued field
defined in a JOIN or IN expression; false if it's not
defined or it's mapping an abstract schema nameThe identification variable to check for what it maps variableName)Determines whether the given identification variable is defining a join or a collection member declaration expressions. |
| public boolean | Returns: true if the variable name is mapping an abstract schema name; false
if it's defined in a collection member declarationThe name of the variable to verify if it's defined in a range variable
declaration in the current query or any parent query variableName)Determines whether the given variable name is an identification variable name used to define an abstract schema name. |
| public boolean | Returns: true if the given variable is defined as a result variable; false
otherwiseThe variable to check if it's a result variable variable)Determines if the given variable is a result variable. |
| public boolean | Returns: true if the current context is for a subquery; false for the
top-level queryDetermines whether this |
| public boolean | Returns: true if the parsing system should parse invalid or incomplete queries;
false when the query is well-formed and validDetermines if the parser is in tolerant mode or is in fast mode. |
| public String | Returns: A value from the givenExpression or an empty string if the given Expression and the LiteralType do not matchThe expression, LiteralType Expression to visitThe type)LiteralType helps to determine what to retrieve from the visited
ExpressionRetrieves the "literal" from the given |
| public void | newSubqueryContext(Expression
The parsed tree representation of the subquery that will become the
current query currentQuery)Changes the state of this context to use the given subquery. |
| public void | setJPQLExpression(JPQLExpression
The parsed representation of the JPQL query to manipulate jpqlExpression)Sets the parsed tree representation of the JPQL query. |
| public void | |
| public void | setTolerant(boolean
Determines if the parsing system should be tolerant, meaning if it should try
to parse invalid or incomplete queries tolerant)Sets whether the parser is in tolerant mode or is in fast mode. |
| protected void | store(JPQLQueryContext
The parent context, which is the context of the parent query parent, Expression The subquery becoming the current query currentQuery)Stores the information contained in the given parent into this one. |
| public String |