public class DeclarationResolver extends Resolver
Resolver
is responsible to visit the current query (which is either the top-level
query or a subquery) and gathers the information from the declaration clause. For a SELECT
or DELETE clause, the information will be retrieved from the FROM clause. For an
UDPATE
clause, it will be retrieved from the unique identification range variable
declaration.Constructor and Description |
---|
DeclarationResolver(DeclarationResolver parent,
JPQLQueryContext queryContext)
Creates a new
DeclarationResolver . |
Modifier and Type | Method and Description |
---|---|
void |
addRangeVariableDeclaration(java.lang.String entityName,
java.lang.String variableName)
Registers a range variable declaration that will be used when a JPQL fragment is parsed.
|
void |
convertUnqualifiedDeclaration(Declaration declaration,
java.lang.String outerVariableName)
Converts the given
Declaration from being set as a range variable declaration to
a path expression declaration. |
void |
dispose()
Disposes the internal data.
|
Declaration |
getDeclaration(java.lang.String variableName)
Retrieves the
Declaration for which the given variable name is used to navigate to the
"root" object. |
java.util.List<Declaration> |
getDeclarations()
Returns the ordered list of
Declarations . |
DeclarationResolver |
getParent()
Returns the parent of this
Resolver . |
IQuery |
getQuery()
Returns the external form representing the JPQL query.
|
Resolver |
getResolver(java.lang.String variableName)
Retrieves the
Resolver mapped with the given identification variable. |
java.util.Set<java.lang.String> |
getResultVariables()
Returns the variables that got defined in the select expression.
|
java.util.Map<IdentificationVariable,java.lang.String> |
getResultVariablesMap()
Returns the map of result variables that got used to define a select expression.
|
boolean |
hasJoins()
Determines whether the JPQL expression has JOIN expressions.
|
boolean |
isCollectionIdentificationVariable(java.lang.String variableName)
Determines whether the given identification variable is defining a JOIN expression or
in a
IN expressions for a collection-valued field. |
boolean |
isRangeIdentificationVariable(java.lang.String variableName)
Determines whether the given variable name is an identification variable name mapping an
entity.
|
boolean |
isResultVariable(java.lang.String variable)
Determines if the given variable is a result variable.
|
void |
populate(Expression expression)
Visits the current query (which is either the top-level query or a subquery) and gathers the
information from the declaration clause.
|
addChild, getChild, getManagedType, getMapping, getParentManagedType, getParentMapping, getParentType, getParentTypeDeclaration, getProvider, getType, getType, getType, getTypeDeclaration, getTypeHelper, getTypeRepository, isNullAllowed, setNullAllowed
public DeclarationResolver(DeclarationResolver parent, JPQLQueryContext queryContext)
DeclarationResolver
.parent
- The parent resolver if this is used for a subquery or null if it's used for the
top-level queryqueryContext
- The context used to query information about the querypublic void addRangeVariableDeclaration(java.lang.String entityName, java.lang.String variableName)
entityName
- The name of the entity to be accessible with the given variable namevariableName
- The identification variable used to navigate to the entitypublic void convertUnqualifiedDeclaration(Declaration declaration, java.lang.String outerVariableName)
Declaration
from being set as a range variable declaration to
a path expression declaration.
In this query "UPDATE Employee SET firstName = 'MODIFIED' WHERE (SELECT COUNT(m) FROM
managedEmployees m) > 0
" managedEmployees is an unqualified
collection-valued path expression (employee.managedEmployees
).
declaration
- The Declaration
that was parsed to range over an abstract schema
name but is actually ranging over a path expressionouterVariableName
- The identification variable coming from the parent identification
variable declarationpublic void dispose()
public Declaration getDeclaration(java.lang.String variableName)
Declaration
for which the given variable name is used to navigate to the
"root" object.variableName
- The name of the identification variable that is used to navigate a "root" objectDeclaration
containing the information about the identification variable declarationpublic java.util.List<Declaration> getDeclarations()
Declarations
.Declarations
of the current query that was parsedpublic DeclarationResolver getParent()
Resolver
.public IQuery getQuery()
public Resolver getResolver(java.lang.String variableName)
Resolver
mapped with the given identification variable. If the
identification is not defined in the declaration traversed by this resolver, than the search
will traverse the parent hierarchy.public java.util.Set<java.lang.String> getResultVariables()
public java.util.Map<IdentificationVariable,java.lang.String> getResultVariablesMap()
public boolean hasJoins()
true
if the query or subquery being traversed contains JOIN
expressions; false
otherwisepublic boolean isCollectionIdentificationVariable(java.lang.String variableName)
IN
expressions for a collection-valued field. If the search didn't find the
identification in this resolver, then it will traverse the parent hierarchy.variableName
- The identification variable to check for what it mapstrue
if the given identification variable maps a collection-valued field
defined in a JOIN
or IN
expression; false
otherwisepublic boolean isRangeIdentificationVariable(java.lang.String variableName)
variableName
- The name of the variable to verify if it's defined in a range variable
declaration in the current query or any parent querytrue
if the variable name is mapping an abstract schema name; false
if it's defined in a collection member declarationpublic boolean isResultVariable(java.lang.String variable)
variable
- The variable to check if it's a result variabletrue
if the given variable is defined as a result variable; false
otherwisepublic void populate(Expression expression)
expression
- The Expression
to visit in order to retrieve the information
contained in the given query's declarationEclipseLink 2.6.3, "build v20160428-59c81c5" API Reference