public class

HqlSqlWalker

extends HqlSqlBaseWalker
implements ParameterBinder.NamedParameterSource ErrorReporter
java.lang.Object
   ↳ HqlSqlBaseWalker
     ↳ org.hibernate.hql.ast.HqlSqlWalker

Class Overview

Implements methods used by the HQL->SQL tree transform grammar (a.k.a. the second phase).

  • Isolates the Hibernate API-specific code from the ANTLR generated code.
  • Handles the SQL fragments generated by the persisters in order to create the SELECT and FROM clauses, taking into account the joins and projections that are implied by the mappings (persister/queryable).
  • Uses SqlASTFactory to create customized AST nodes.

See Also

Summary

Public Constructors
HqlSqlWalker(QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole)
Create a new tree transformer.
Public Methods
void addQuerySpaces(Serializable[] spaces)
ASTPrinter getASTPrinter()
AliasGenerator getAliasGenerator()
ArrayList getAssignmentSpecifications()
String getCollectionFilterRole()
FromClause getCurrentFromClause()
Map getEnabledFilters()
FromClause getFinalFromClause()
int getImpliedJoinType()
LiteralProcessor getLiteralProcessor()
int[] getNamedParameterLocations(String name)
Returns the locations of all occurrences of the named parameter.
int getNumberOfParametersInSetClause()
ArrayList getParameters()
ParseErrorHandler getParseErrorHandler()
Set getQuerySpaces()
Returns the set of unique query spaces (a.k.a.
String[] getReturnAliases()
Type[] getReturnTypes()
SelectClause getSelectClause()
SessionFactoryHelper getSessionFactoryHelper()
Map getTokenReplacements()
boolean isFilter()
boolean isShallowQuery()
static void panic()
void reportError(RecognitionException e)
void reportWarning(String s)
static boolean supportsIdGenWithBulkInsertion(IdentifierGenerator generator)
void traceIn(String ruleName, AST tree)
void traceOut(String ruleName, AST tree)
Protected Methods
void beforeSelectClause()
AST createFromElement(String path, AST alias, AST propertyFetch)
AST createFromFilterElement(AST filterEntity, AST alias)
void createFromJoinElement(AST path, AST alias, int joinType, AST fetchNode, AST propertyFetch, AST with)
AST createIntoClause(String path, AST propertySpec)
void evaluateAssignment(AST eq)
AST generateNamedParameter(AST delimiterNode, AST nameNode)
AST generatePositionalParameter(AST inputNode)
void handleResultVariableRef(AST resultVariableRef)
boolean isNonQualifiedPropertyRef(AST ident)
boolean isOrderExpressionResultVariableRef(AST orderExpressionNode)
void lookupAlias(AST aliasRef)
AST lookupNonQualifiedProperty(AST property)
AST lookupProperty(AST dot, boolean root, boolean inSelect)
void postProcessDML(RestrictableStatement statement)
void postProcessDelete(AST delete)
void postProcessInsert(AST insert)
void postProcessUpdate(AST update)
void prepareArithmeticOperator(AST operator)
void prepareFromClauseInputTree(AST fromClauseInput)
void prepareLogicOperator(AST operator)
void prepareVersioned(AST updateNode, AST versioned)
void processAggregation(AST node, boolean inSelect)
void processBoolean(AST constant)
void processConstant(AST constant)
void processConstructor(AST constructor)
void processFunction(AST functionCall, boolean inSelect)
void processIndex(AST indexOp)
void processNumericLiteral(AST literal)
void processQuery(AST select, AST query)
void pushFromClause(AST fromNode, AST inputFromNode)
Sets the current 'FROM' context.
void resolve(AST node)
void resolveSelectExpression(AST node)
void setAlias(AST selectExpr, AST ident)
void setImpliedJoinType(int joinType)
void validateMapPropertyExpression(AST node)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.engine.ParameterBinder.NamedParameterSource
From interface org.hibernate.hql.ast.ErrorReporter

Public Constructors

public HqlSqlWalker (QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole)

Create a new tree transformer.

Parameters
qti Back pointer to the query translator implementation that is using this tree transform.
sfi The session factory implementor where the Hibernate mappings can be found.
parser A reference to the phase-1 parser
tokenReplacements Registers the token replacement map with the walker. This map will be used to substitute function names and constants.
collectionRole The collection role name of the collection used as the basis for the filter, NULL if this is not a collection filter compilation.

Public Methods

public void addQuerySpaces (Serializable[] spaces)

public ASTPrinter getASTPrinter ()

public AliasGenerator getAliasGenerator ()

public ArrayList getAssignmentSpecifications ()

public String getCollectionFilterRole ()

public FromClause getCurrentFromClause ()

public Map getEnabledFilters ()

public FromClause getFinalFromClause ()

public int getImpliedJoinType ()

public LiteralProcessor getLiteralProcessor ()

public int[] getNamedParameterLocations (String name)

Returns the locations of all occurrences of the named parameter.

public int getNumberOfParametersInSetClause ()

public ArrayList getParameters ()

public ParseErrorHandler getParseErrorHandler ()

public Set getQuerySpaces ()

Returns the set of unique query spaces (a.k.a. table names) that occurred in the query.

Returns
  • A set of table names (Strings).

public String[] getReturnAliases ()

public Type[] getReturnTypes ()

public SelectClause getSelectClause ()

public SessionFactoryHelper getSessionFactoryHelper ()

public Map getTokenReplacements ()

public boolean isFilter ()

public boolean isShallowQuery ()

public static void panic ()

public void reportError (RecognitionException e)

public void reportWarning (String s)

public static boolean supportsIdGenWithBulkInsertion (IdentifierGenerator generator)

public void traceIn (String ruleName, AST tree)

public void traceOut (String ruleName, AST tree)

Protected Methods

protected void beforeSelectClause ()

Throws
SemanticException

protected AST createFromElement (String path, AST alias, AST propertyFetch)

Throws
SemanticException

protected AST createFromFilterElement (AST filterEntity, AST alias)

Throws
SemanticException

protected void createFromJoinElement (AST path, AST alias, int joinType, AST fetchNode, AST propertyFetch, AST with)

Throws
SemanticException

protected AST createIntoClause (String path, AST propertySpec)

Throws
SemanticException

protected void evaluateAssignment (AST eq)

Throws
SemanticException

protected AST generateNamedParameter (AST delimiterNode, AST nameNode)

Throws
SemanticException

protected AST generatePositionalParameter (AST inputNode)

Throws
SemanticException

protected void handleResultVariableRef (AST resultVariableRef)

Throws
SemanticException

protected boolean isNonQualifiedPropertyRef (AST ident)

protected boolean isOrderExpressionResultVariableRef (AST orderExpressionNode)

Throws
SemanticException

protected void lookupAlias (AST aliasRef)

Throws
SemanticException

protected AST lookupNonQualifiedProperty (AST property)

Throws
SemanticException

protected AST lookupProperty (AST dot, boolean root, boolean inSelect)

Throws
SemanticException

protected void postProcessDML (RestrictableStatement statement)

Throws
SemanticException

protected void postProcessDelete (AST delete)

Throws
SemanticException

protected void postProcessInsert (AST insert)

Throws
QueryException
SemanticException

protected void postProcessUpdate (AST update)

Throws
SemanticException

protected void prepareArithmeticOperator (AST operator)

Throws
SemanticException

protected void prepareFromClauseInputTree (AST fromClauseInput)

protected void prepareLogicOperator (AST operator)

Throws
SemanticException

protected void prepareVersioned (AST updateNode, AST versioned)

Throws
SemanticException

protected void processAggregation (AST node, boolean inSelect)

Throws
SemanticException

protected void processBoolean (AST constant)

Throws
SemanticException

protected void processConstant (AST constant)

Throws
SemanticException

protected void processConstructor (AST constructor)

Throws
SemanticException

protected void processFunction (AST functionCall, boolean inSelect)

Throws
SemanticException

protected void processIndex (AST indexOp)

Throws
SemanticException

protected void processNumericLiteral (AST literal)

protected void processQuery (AST select, AST query)

Throws
SemanticException

protected void pushFromClause (AST fromNode, AST inputFromNode)

Sets the current 'FROM' context.

Parameters
fromNode The new 'FROM' context.
inputFromNode The from node from the input AST.

protected void resolve (AST node)

Throws
SemanticException

protected void resolveSelectExpression (AST node)

Throws
SemanticException

protected void setAlias (AST selectExpr, AST ident)

protected void setImpliedJoinType (int joinType)

protected void validateMapPropertyExpression (AST node)

Throws
SemanticException