Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.jpa.internal.jpql
Class DeclarationResolver

java.lang.Object
  extended by org.eclipse.persistence.jpa.internal.jpql.Resolver
      extended by org.eclipse.persistence.jpa.internal.jpql.DeclarationResolver


public final class DeclarationResolver
extends Resolver

This 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.

Since:
2.3
Version:
2.3
Author:
Pascal Filion

Nested Class Summary
static class DeclarationResolver.Declaration
          A Declaration represents either an identification variable declaration or a collection member declaration.
private  class DeclarationResolver.DeclarationVisitor
           
private  class DeclarationResolver.QualifyRangeDeclarationVisitor
           

 

Field Summary
private  java.util.List<DeclarationResolver.Declaration> declarations
          The Declarations of the current query that was parsed.
private  DeclarationResolver.DeclarationVisitor declarationVisitor
          This visitor is responsible to visit the current query's declaration and populate this resolver with the list of declarations.
private  DeclarationResolver.QualifyRangeDeclarationVisitor qualifyRangeDeclarationVisitor
          This visitor is responsible to convert the abstract schema name into a path expression.
private  JPQLQueryContext queryContext
          The context used to query information about the query.
private  java.util.Map<java.lang.String,Resolver> resolvers
          The identification variable names mapped to their resolvers.
private  java.util.Map<IdentificationVariable,java.lang.String> resultVariables
          The variables identifying the select expressions, if any was defined or an empty set if none were defined.

 

Constructor Summary
DeclarationResolver(DeclarationResolver parent, JPQLQueryContext queryContext)
          Creates a new DeclarationResolver.

 

Method Summary
 void accept(ResolverVisitor visitor)
          Visits this Resolver by the given visitor.
(package private)  IType buildType()
          Resolves the IType of the property handled by this Resolver.
(package private)  ITypeDeclaration buildTypeDeclaration()
          Resolves the ITypeDeclaration of the property handled by this Resolver.
(package private)  void checkParent(Resolver parent)
          
(package private)  void convertUnqualifiedDeclaration(DeclarationResolver.Declaration declaration, java.lang.String outerVariableName)
          Converts the given DeclarationResolver.Declaration from being set as a range variable declaration to a path expression declaration.
private  DeclarationResolver.DeclarationVisitor declarationVisitor()
           
(package private)  void dispose()
          Disposes the internal data.
(package private)  java.util.List<DeclarationResolver.Declaration> getDeclarations()
          Returns the ordered list of Declarations.
(package private)  java.util.Collection<JoinFetch> getJoinFetches(java.lang.String variableName)
          Returns the parsed representation of a JOIN FETCH that were defined in the same declaration than the given range identification variable name.
private  java.util.Collection<JoinFetch> getJoinFetchesImp(java.lang.String variableName)
           
 DeclarationResolver getParent()
          Returns the parent of this Resolver.
(package private)  IQuery getQuery()
          Returns the external form representing the JPQL query.
(package private)  Resolver getResolver(java.lang.String variableName)
          Retrieves the Resolver mapped with the given identification variable.
private  Resolver getResolverImp(java.lang.String variableName)
           
(package private)  java.util.Set<java.lang.String> getResultVariables()
          Returns the variables that got defined in the select expression.
(package private)  boolean hasJoins()
          Determines whether the JPQL expression has JOIN expressions.
private  void initialize(JPQLQueryContext queryContext)
          Initializes this DeclarationResolver.
(package private)  boolean isCollectionIdentificationVariable(java.lang.String variableName)
          Determines whether the given identification variable is defining a JOIN or IN expressions for a collection-valued field.
private  boolean isCollectionIdentificationVariableImp(java.lang.String variableName)
           
(package private)  boolean isRangeIdentificationVariable(java.lang.String variableName)
          Determines whether the given variable name is an identification variable name used to define an abstract schema name.
private  boolean isRangeIdentificationVariableImp(java.lang.String variableName)
           
(package private)  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.
private  DeclarationResolver.QualifyRangeDeclarationVisitor qualifyRangeDeclarationVisitor()
           
private  java.lang.String visitDeclaration(Expression expression, Expression identificationVariable)
           

 

Methods inherited from class org.eclipse.persistence.jpa.internal.jpql.Resolver
addChild, getChild, getManagedType, getMapping, getParentManagedType, getParentMapping, getParentType, getParentTypeDeclaration, getProvider, getType, getType, getType, getTypeDeclaration, getTypeHelper, getTypeRepository, isNullAllowed, setNullAllowed

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

declarations

private java.util.List<DeclarationResolver.Declaration> declarations
The Declarations of the current query that was parsed.

declarationVisitor

private DeclarationResolver.DeclarationVisitor declarationVisitor
This visitor is responsible to visit the current query's declaration and populate this resolver with the list of declarations.

qualifyRangeDeclarationVisitor

private DeclarationResolver.QualifyRangeDeclarationVisitor qualifyRangeDeclarationVisitor
This visitor is responsible to convert the abstract schema name into a path expression.

queryContext

private JPQLQueryContext queryContext
The context used to query information about the query.

resolvers

private java.util.Map<java.lang.String,Resolver> resolvers
The identification variable names mapped to their resolvers.

resultVariables

private java.util.Map<IdentificationVariable,java.lang.String> resultVariables
The variables identifying the select expressions, if any was defined or an empty set if none were defined.

Constructor Detail

DeclarationResolver

DeclarationResolver(DeclarationResolver parent,
                    JPQLQueryContext queryContext)
Creates a new DeclarationResolver.
Parameters:
parent - The parent resolver if this is used for a subquery or null if it's used for the top-level query
queryContext - The context used to query information about the query

Method Detail

accept

public void accept(ResolverVisitor visitor)
Visits this Resolver by the given visitor.
Specified by:
accept in class Resolver
Parameters:
visitor - The visitor to visit this object

buildType

IType buildType()
Resolves the IType of the property handled by this Resolver.
Overrides:
buildType in class Resolver
Returns:
Either the IType that was resolved by this Resolver or the IType for IType.UNRESOLVABLE_TYPE if it could not be resolved

buildTypeDeclaration

ITypeDeclaration buildTypeDeclaration()
Resolves the ITypeDeclaration of the property handled by this Resolver.
Specified by:
buildTypeDeclaration in class Resolver
Returns:
Either the ITypeDeclaration that was resolved by this Resolver or the ITypeDeclaration for IType.UNRESOLVABLE_TYPE if it could not be resolved

checkParent

void checkParent(Resolver parent)
Overrides:
checkParent in class Resolver

convertUnqualifiedDeclaration

void convertUnqualifiedDeclaration(DeclarationResolver.Declaration declaration,
                                   java.lang.String outerVariableName)
Converts the given DeclarationResolver.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).

Parameters:
declaration - The DeclarationResolver.Declaration that was parsed to range over an abstract schema name but is actually ranging over a path expression
outerVariableName - The identification variable coming from the parent identification variable declaration

declarationVisitor

private DeclarationResolver.DeclarationVisitor declarationVisitor()

dispose

void dispose()
Disposes the internal data.

getDeclarations

java.util.List<DeclarationResolver.Declaration> getDeclarations()
Returns the ordered list of Declarations.
Returns:
The Declarations of the current query that was parsed

getJoinFetches

java.util.Collection<JoinFetch> getJoinFetches(java.lang.String variableName)
Returns the parsed representation of a JOIN FETCH that were defined in the same declaration than the given range identification variable name.
Parameters:
variableName - The name of the identification variable that should be used to define an abstract schema name
Returns:
The JOIN FETCH expressions used in the same declaration or an empty collection if none was defined

getJoinFetchesImp

private java.util.Collection<JoinFetch> getJoinFetchesImp(java.lang.String variableName)

getParent

public DeclarationResolver getParent()
Returns the parent of this Resolver.
Overrides:
getParent in class Resolver
Returns:
The parent of this Resolver

getQuery

IQuery getQuery()
Returns the external form representing the JPQL query.
Overrides:
getQuery in class Resolver
Returns:
The external form of the JPQL query

getResolver

Resolver getResolver(java.lang.String variableName)
Retrieves the 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.
Parameters:
variableName - The identification variable that maps a Resolver
Returns:
The Resolver mapped with the given identification variable

getResolverImp

private Resolver getResolverImp(java.lang.String variableName)

getResultVariables

java.util.Set<java.lang.String> getResultVariables()
Returns the variables that got defined in the select expression. This only applies to JPQL queries built for JPA 2.0.
Returns:
The variables identifying the select expressions, if any was defined or an empty set if none were defined

hasJoins

boolean hasJoins()
Determines whether the JPQL expression has JOIN expressions.
Returns:
true if the query or subquery being traversed contains JOIN expressions; false otherwise

initialize

private void initialize(JPQLQueryContext queryContext)
Initializes this DeclarationResolver.
Parameters:
queryContext - The context used to query information about the query

isCollectionIdentificationVariable

boolean isCollectionIdentificationVariable(java.lang.String variableName)
Determines whether the given identification variable is defining a JOIN or IN expressions for a collection-valued field.
Parameters:
variableName - The identification variable to check for what it maps
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 name

isCollectionIdentificationVariableImp

private boolean isCollectionIdentificationVariableImp(java.lang.String variableName)

isRangeIdentificationVariable

boolean isRangeIdentificationVariable(java.lang.String variableName)
Determines whether the given variable name is an identification variable name used to define an abstract schema name.
Parameters:
variableName - The name of the variable to verify if it's defined in a range variable declaration in the current query or any parent query
Returns:
true if the variable name is mapping an abstract schema name; false if it's defined in a collection member declaration

isRangeIdentificationVariableImp

private boolean isRangeIdentificationVariableImp(java.lang.String variableName)

populate

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.
Parameters:
expression - The Expression to visit in order to retrieve the information contained in the given query's declaration

qualifyRangeDeclarationVisitor

private DeclarationResolver.QualifyRangeDeclarationVisitor qualifyRangeDeclarationVisitor()

visitDeclaration

private java.lang.String visitDeclaration(Expression expression,
                                          Expression identificationVariable)

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.