org.hibernate.hql.ast
Class HqlSqlWalker

java.lang.Object
  extended byantlr.TreeParser
      extended byorg.hibernate.hql.antlr.HqlSqlBaseWalker
          extended byorg.hibernate.hql.ast.HqlSqlWalker
All Implemented Interfaces:
ErrorReporter, HqlSqlTokenTypes

public class HqlSqlWalker
extends HqlSqlBaseWalker
implements ErrorReporter

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

See Also:
SqlASTFactory

Field Summary
 
Fields inherited from class org.hibernate.hql.antlr.HqlSqlBaseWalker
_tokenNames, _tokenSet_0
 
Fields inherited from class antlr.TreeParser
_retTree, astFactory, ASTNULL, inputState, returnAST, tokenNames, traceDepth
 
Fields inherited from interface org.hibernate.hql.antlr.HqlSqlTokenTypes
AGGREGATE, ALIAS, ALIAS_REF, ALL, AND, ANY, AS, ASCENDING, AVG, BETWEEN, BOGUS, BOTH, CASE, CASE2, CLASS, CLOSE, CLOSE_BRACKET, COLON, COMMA, CONCAT, CONSTANT, CONSTRUCTOR, COUNT, DELETE, DESCENDING, DISTINCT, DIV, DOT, ELEMENTS, ELSE, EMPTY, END, EOF, EQ, ESCAPE, ESCqs, EXISTS, EXPONENT, EXPR_LIST, FALSE, FETCH, FILTER_ENTITY, FILTERS, FLOAT_SUFFIX, FROM, FROM_FRAGMENT, FULL, GE, GROUP, GT, HAVING, HEX_DIGIT, IDENT, IMPLIED_FROM, IN, IN_LIST, INDEX_OP, INDICES, INNER, IS, IS_NOT_NULL, IS_NULL, JOIN, JOIN_FRAGMENT, LE, LEADING, LEFT, LEFT_OUTER, LIKE, LITERAL_ascending, LITERAL_by, LITERAL_descending, LT, MAX, MEMBER, METHOD_CALL, METHOD_NAME, MIN, MINUS, NAMED_PARAM, NE, NEW, NOT, NOT_BETWEEN, NOT_IN, NOT_LIKE, NULL, NULL_TREE_LOOKAHEAD, NUM_DOUBLE, NUM_FLOAT, NUM_INT, NUM_LONG, OBJECT, OF, ON, OPEN, OPEN_BRACKET, OR, ORDER, ORDER_ELEMENT, OUTER, PARAM, PLUS, PROPERTIES, PROPERTY_REF, QUERY, QUOTED_STRING, RANGE, RIGHT, RIGHT_OUTER, ROW_STAR, SELECT, SELECT_CLAUSE, SELECT_COLUMNS, SELECT_EXPR, SELECT_FROM, SET, SOME, SQL_NE, SQL_TOKEN, STAR, SUM, THEN, THETA_JOINS, TRAILING, TRUE, UNARY_MINUS, UNARY_PLUS, UNION, UPDATE, VECTOR_EXPR, WEIRD_IDENT, WHEN, WHERE, WS
 
Constructor Summary
HqlSqlWalker(QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole)
          Create a new tree transformer.
 
Method Summary
protected  void beforeSelectClause()
           
protected  antlr.collections.AST createFromElement(String path, antlr.collections.AST alias, antlr.collections.AST propertyFetch)
           
protected  antlr.collections.AST createFromFilterElement(antlr.collections.AST filterEntity, antlr.collections.AST alias)
           
protected  void createFromJoinElement(antlr.collections.AST path, antlr.collections.AST alias, int joinType, antlr.collections.AST fetchNode, antlr.collections.AST propertyFetch)
           
 org.hibernate.hql.ast.AliasGenerator getAliasGenerator()
           
 Map getEnabledFilters()
           
 org.hibernate.hql.ast.FromClause getFinalFromClause()
           
 ParseErrorHandler getParseErrorHandler()
           
 String[] getReturnAliases()
           
 Type[] getReturnTypes()
           
 SelectClause getSelectClause()
           
 org.hibernate.hql.ast.SessionFactoryHelper getSessionFactoryHelper()
           
 Map getTokenReplacements()
           
 boolean isShallowQuery()
           
 boolean isSubQuery()
           
protected  void lookupAlias(antlr.collections.AST aliasRef)
           
protected  antlr.collections.AST lookupProperty(antlr.collections.AST dot, boolean root, boolean inSelect)
           
protected  void namedParameter(antlr.collections.AST namedParameter)
           
protected  void positionalParameter(antlr.collections.AST parameter)
           
protected  void postProcessDelete(antlr.collections.AST delete)
           
protected  void postProcessUpdate(antlr.collections.AST update)
           
protected  void prepareFromClauseInputTree(antlr.collections.AST fromClauseInput)
          Pre-process the from clause input tree.
protected  void processBoolean(antlr.collections.AST constant)
           
protected  void processConstant(antlr.collections.AST constant)
           
protected  void processConstructor(antlr.collections.AST constructor)
           
protected  void processFunction(antlr.collections.AST functionCall, boolean inSelect)
           
protected  void processIndex(antlr.collections.AST indexOp)
           
protected  void processQuery(antlr.collections.AST select, antlr.collections.AST query)
           
protected  void pushFromClause(antlr.collections.AST fromNode, antlr.collections.AST inputFromNode)
          Sets the current 'FROM' context.
 void reportError(antlr.RecognitionException e)
           
 void reportError(String s)
           
 void reportWarning(String s)
           
protected  void resolve(antlr.collections.AST node)
           
protected  void resolveSelectExpression(antlr.collections.AST node)
           
protected  void setImpliedJoinType(int joinType)
           
 
Methods inherited from class org.hibernate.hql.antlr.HqlSqlBaseWalker
addrExpr, addrExprLhs, afterQuery, aggregateExpr, aliasedSelectExpr, aliasRef, arithmeticExpr, assignment, beforeQuery, caseExpr, collectionFunction, collectionFunctionOrSubselect, comparisonExpr, constant, constructor, count, deleteStatement, expr, exprOrSubquery, fromClause, fromElement, fromElementList, functionCall, getStatementType, groupClause, identifier, inLhs, inRhs, isInFrom, isInFunctionCall, isInSelect, isSelectStatement, joinElement, joinType, literal, logicalExpr, newValue, nonNestedPropertyRef, orderClause, orderExprs, parameter, path, propertyName, propertyRef, propertyRefLhs, query, selectClause, selectExpr, selectExprList, selectStatement, setClause, statement, updateStatement, whereClause
 
Methods inherited from class antlr.TreeParser
getAST, getASTFactory, getTokenName, getTokenNames, match, match, matchNot, panic, setASTFactory, setASTNodeClass, setASTNodeType, traceIn, traceIndent, traceOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HqlSqlWalker

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 -
tokenReplacements - Registers the token replacement map with the walker. This map will be used to substitute function names and constants.
collectionRole - the role name of the collection used as the basis for the filter, NULL if this
Method Detail

prepareFromClauseInputTree

protected void prepareFromClauseInputTree(antlr.collections.AST fromClauseInput)
Description copied from class: HqlSqlBaseWalker
Pre-process the from clause input tree.

Overrides:
prepareFromClauseInputTree in class HqlSqlBaseWalker

getSessionFactoryHelper

public org.hibernate.hql.ast.SessionFactoryHelper getSessionFactoryHelper()

getTokenReplacements

public Map getTokenReplacements()

getAliasGenerator

public org.hibernate.hql.ast.AliasGenerator getAliasGenerator()

getParseErrorHandler

public ParseErrorHandler getParseErrorHandler()

reportError

public void reportError(antlr.RecognitionException e)
Specified by:
reportError in interface ErrorReporter

reportError

public void reportError(String s)
Specified by:
reportError in interface ErrorReporter

reportWarning

public void reportWarning(String s)
Specified by:
reportWarning in interface ErrorReporter

createFromElement

protected antlr.collections.AST createFromElement(String path,
                                                  antlr.collections.AST alias,
                                                  antlr.collections.AST propertyFetch)
                                           throws antlr.SemanticException
Overrides:
createFromElement in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

createFromFilterElement

protected antlr.collections.AST createFromFilterElement(antlr.collections.AST filterEntity,
                                                        antlr.collections.AST alias)
                                                 throws antlr.SemanticException
Overrides:
createFromFilterElement in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

createFromJoinElement

protected void createFromJoinElement(antlr.collections.AST path,
                                     antlr.collections.AST alias,
                                     int joinType,
                                     antlr.collections.AST fetchNode,
                                     antlr.collections.AST propertyFetch)
                              throws antlr.SemanticException
Overrides:
createFromJoinElement in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

pushFromClause

protected void pushFromClause(antlr.collections.AST fromNode,
                              antlr.collections.AST inputFromNode)
Sets the current 'FROM' context.

Overrides:
pushFromClause in class HqlSqlBaseWalker
Parameters:
fromNode - The new 'FROM' context.
inputFromNode - The from node from the input AST.

lookupAlias

protected void lookupAlias(antlr.collections.AST aliasRef)
                    throws antlr.SemanticException
Overrides:
lookupAlias in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

setImpliedJoinType

protected void setImpliedJoinType(int joinType)
Overrides:
setImpliedJoinType in class HqlSqlBaseWalker

lookupProperty

protected antlr.collections.AST lookupProperty(antlr.collections.AST dot,
                                               boolean root,
                                               boolean inSelect)
                                        throws antlr.SemanticException
Overrides:
lookupProperty in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processQuery

protected void processQuery(antlr.collections.AST select,
                            antlr.collections.AST query)
                     throws antlr.SemanticException
Overrides:
processQuery in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

postProcessUpdate

protected void postProcessUpdate(antlr.collections.AST update)
                          throws antlr.SemanticException
Overrides:
postProcessUpdate in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

postProcessDelete

protected void postProcessDelete(antlr.collections.AST delete)
                          throws antlr.SemanticException
Overrides:
postProcessDelete in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

resolve

protected void resolve(antlr.collections.AST node)
                throws antlr.SemanticException
Overrides:
resolve in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

resolveSelectExpression

protected void resolveSelectExpression(antlr.collections.AST node)
                                throws antlr.SemanticException
Overrides:
resolveSelectExpression in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

beforeSelectClause

protected void beforeSelectClause()
                           throws antlr.SemanticException
Overrides:
beforeSelectClause in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

positionalParameter

protected void positionalParameter(antlr.collections.AST parameter)
                            throws antlr.SemanticException
Overrides:
positionalParameter in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processConstant

protected void processConstant(antlr.collections.AST constant)
                        throws antlr.SemanticException
Overrides:
processConstant in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processBoolean

protected void processBoolean(antlr.collections.AST constant)
                       throws antlr.SemanticException
Overrides:
processBoolean in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processIndex

protected void processIndex(antlr.collections.AST indexOp)
                     throws antlr.SemanticException
Overrides:
processIndex in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processFunction

protected void processFunction(antlr.collections.AST functionCall,
                               boolean inSelect)
                        throws antlr.SemanticException
Overrides:
processFunction in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

processConstructor

protected void processConstructor(antlr.collections.AST constructor)
                           throws antlr.SemanticException
Overrides:
processConstructor in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

namedParameter

protected void namedParameter(antlr.collections.AST namedParameter)
                       throws antlr.SemanticException
Overrides:
namedParameter in class HqlSqlBaseWalker
Throws:
antlr.SemanticException

getReturnTypes

public Type[] getReturnTypes()

getReturnAliases

public String[] getReturnAliases()

isSubQuery

public boolean isSubQuery()
Overrides:
isSubQuery in class HqlSqlBaseWalker

getSelectClause

public SelectClause getSelectClause()

getFinalFromClause

public org.hibernate.hql.ast.FromClause getFinalFromClause()

isShallowQuery

public boolean isShallowQuery()

getEnabledFilters

public Map getEnabledFilters()