类 HqlSqlWalker
- java.lang.Object
-
- antlr.TreeParser
-
- org.hibernate.hql.internal.antlr.HqlSqlBaseWalker
-
- org.hibernate.hql.internal.ast.HqlSqlWalker
-
public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, ParameterBinder.NamedParameterSource
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.
- 另请参阅:
SqlASTFactory
-
-
字段概要
-
从类继承的字段 org.hibernate.hql.internal.antlr.HqlSqlBaseWalker
_tokenNames, _tokenSet_0, _tokenSet_1
-
从接口继承的字段 org.hibernate.hql.internal.antlr.HqlSqlTokenTypes
AGGREGATE, ALIAS, ALIAS_REF, ALL, AND, ANY, AS, ASCENDING, AVG, BETWEEN, BOGUS, BOTH, CASE, CASE2, CAST, CLASS, CLOSE, CLOSE_BRACKET, COLON, COMMA, CONCAT, CONSTANT, CONSTRUCTOR, COUNT, DELETE, DESCENDING, DISTINCT, DIV, DOT, ELEMENTS, ELSE, EMPTY, END, ENTITY_JOIN, ENTRY, EOF, EQ, ESCAPE, ESCqs, EXISTS, EXPONENT, EXPR_LIST, FALSE, FETCH, FILTER_ENTITY, FILTERS, FIRST, FLOAT_SUFFIX, FROM, FROM_FRAGMENT, FULL, GE, GROUP, GT, HAVING, HEX_DIGIT, ID_LETTER, ID_START_LETTER, IDENT, IMPLIED_FROM, IN, IN_LIST, INDEX_OP, INDICES, INNER, INSERT, INTO, IS, IS_NOT_NULL, IS_NULL, JAVA_CONSTANT, JOIN, JOIN_FRAGMENT, KEY, LAST, LE, LEADING, LEFT, LEFT_OUTER, LIKE, LITERAL_ascending, LITERAL_by, LITERAL_descending, LT, MAX, MEMBER, METHOD_CALL, METHOD_NAME, MIN, MINUS, MOD, NAMED_PARAM, NE, NEW, NOT, NOT_BETWEEN, NOT_IN, NOT_LIKE, NULL, NULL_TREE_LOOKAHEAD, NULLS, NUM_BIG_DECIMAL, NUM_BIG_INTEGER, 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, RESULT_VARIABLE_REF, 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, UPDATE, VALUE, VECTOR_EXPR, VERSIONED, WEIRD_IDENT, WHEN, WHERE, WITH, WS
-
-
构造器概要
构造器 构造器 说明 HqlSqlWalker(QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole)Create a new tree transformer.
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddQuerySpaces(Serializable[] spaces)protected voidbeforeSelectClause()protected antlr.collections.ASTcreateFromElement(String path, antlr.collections.AST alias, antlr.collections.AST propertyFetch)protected antlr.collections.ASTcreateFromFilterElement(antlr.collections.AST filterEntity, antlr.collections.AST alias)protected voidcreateFromJoinElement(antlr.collections.AST path, antlr.collections.AST alias, int joinType, antlr.collections.AST fetchNode, antlr.collections.AST propertyFetch, antlr.collections.AST with)protected antlr.collections.ASTcreateIntoClause(String path, antlr.collections.AST propertySpec)protected voidevaluateAssignment(antlr.collections.AST eq)protected voidfinishFromClause(antlr.collections.AST fromClause)protected antlr.collections.ASTgenerateNamedParameter(antlr.collections.AST delimiterNode, antlr.collections.AST nameNode)protected antlr.collections.ASTgeneratePositionalParameter(antlr.collections.AST delimiterNode, antlr.collections.AST numberNode)AliasGeneratorgetAliasGenerator()ArrayListgetAssignmentSpecifications()ASTPrintergetASTPrinter()StringgetCollectionFilterRole()FromClausegetCurrentFromClause()DialectgetDialect()MapgetEnabledFilters()FromClausegetFinalFromClause()JoinTypegetImpliedJoinType()LiteralProcessorgetLiteralProcessor()int[]getNamedParameterLocations(String name)Returns the locations of all occurrences of the named parameter.intgetNumberOfParametersInSetClause()ArrayList<ParameterSpecification>getParameterSpecs()ParseErrorHandlergetParseErrorHandler()Set<Serializable>getQuerySpaces()Returns the set of unique query spaces (a.k.a.String[]getReturnAliases()Type[]getReturnTypes()SelectClausegetSelectClause()SessionFactoryHelpergetSessionFactoryHelper()MapgetTokenReplacements()Set<String>getTreatAsDeclarationsByPath(String path)protected voidhandleResultVariableRef(antlr.collections.AST resultVariableRef)booleanisFilter()protected booleanisGroupExpressionResultVariableRef(antlr.collections.AST groupExpressionNode)booleanisInEntityGraph()protected booleanisNonQualifiedPropertyRef(antlr.collections.AST ident)protected booleanisOrderExpressionResultVariableRef(antlr.collections.AST orderExpressionNode)booleanisShallowQuery()protected voidlookupAlias(antlr.collections.AST aliasRef)protected antlr.collections.ASTlookupNonQualifiedProperty(antlr.collections.AST property)protected antlr.collections.ASTlookupProperty(antlr.collections.AST dot, boolean root, boolean inSelect)static voidpanic()protected voidpostProcessDelete(antlr.collections.AST delete)protected voidpostProcessDML(RestrictableStatement statement)protected voidpostProcessInsert(antlr.collections.AST insert)protected voidpostProcessUpdate(antlr.collections.AST update)protected voidprepareArithmeticOperator(antlr.collections.AST operator)protected voidprepareFromClauseInputTree(antlr.collections.AST fromClauseInput)Pre-process the from clause input tree.protected voidprepareLogicOperator(antlr.collections.AST operator)protected voidprepareVersioned(antlr.collections.AST updateNode, antlr.collections.AST versioned)protected voidprocessAggregation(antlr.collections.AST node, boolean inSelect)protected voidprocessBoolean(antlr.collections.AST constant)protected voidprocessCastFunction(antlr.collections.AST castFunctionCall, boolean inSelect)protected voidprocessConstant(antlr.collections.AST constant)protected voidprocessConstructor(antlr.collections.AST constructor)protected voidprocessFunction(antlr.collections.AST functionCall, boolean inSelect)protected voidprocessIndex(antlr.collections.AST indexOp)protected voidprocessNumericLiteral(antlr.collections.AST literal)protected voidprocessQuery(antlr.collections.AST select, antlr.collections.AST query)protected voidpushFromClause(antlr.collections.AST fromNode, antlr.collections.AST inputFromNode)Sets the current 'FROM' context.voidreportError(antlr.RecognitionException e)voidreportError(String s)voidreportWarning(String s)protected voidresolve(antlr.collections.AST node)protected voidresolve(antlr.collections.AST node, antlr.collections.AST predicateNode)protected voidresolveSelectExpression(antlr.collections.AST node)protected voidsetAlias(antlr.collections.AST selectExpr, antlr.collections.AST ident)protected voidsetImpliedJoinType(int joinType)voidtraceIn(String ruleName, antlr.collections.AST tree)voidtraceOut(String ruleName, antlr.collections.AST tree)protected voidvalidateMapPropertyExpression(antlr.collections.AST node)-
从类继承的方法 org.hibernate.hql.internal.antlr.HqlSqlBaseWalker
addrExpr, addrExprLhs, aggregateExpr, aliasedSelectExpr, aliasRef, arithmeticExpr, assignment, caseExpr, collectionFunction, collectionFunctionOrSubselect, comparisonExpr, constant, constructor, count, deleteStatement, elseClause, expr, expressionOrSubQuery, exprOrSubquery, fromClause, fromElement, fromElementList, functionCall, getCurrentClauseType, getCurrentStatementType, getCurrentTopLevelClauseType, getStatementType, groupClause, identifier, inRhs, insertablePropertySpec, insertStatement, intoClause, isComparativeExpressionClause, isInCase, isInCount, isInCountDistinct, isInFrom, isInFunctionCall, isInSelect, isSelectStatement, isSubQuery, joinElement, joinType, literal, logicalExpr, mapComponentReference, mapPropertyExpression, newValue, nullOrdering, nullPrecedence, numericInteger, orderClause, orderExpr, orderExprs, parameter, path, pathAsIdent, processMapComponentReference, propertyName, propertyRef, propertyRefLhs, query, resultVariableRef, searchedCaseExpression, searchedCaseWhenClause, selectClause, selectExpr, selectExprList, selectStatement, setClause, simpleCaseExpression, simpleCaseWhenClause, statement, updateStatement, whereClause, withClause
-
-
-
-
构造器详细资料
-
HqlSqlWalker
public HqlSqlWalker(QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole)
Create a new tree transformer.- 参数:
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 parsertokenReplacements- 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.
-
-
方法详细资料
-
traceIn
public void traceIn(String ruleName, antlr.collections.AST tree)
- 覆盖:
traceIn在类中antlr.TreeParser
-
traceOut
public void traceOut(String ruleName, antlr.collections.AST tree)
- 覆盖:
traceOut在类中antlr.TreeParser
-
prepareFromClauseInputTree
protected void prepareFromClauseInputTree(antlr.collections.AST fromClauseInput)
从类复制的说明:HqlSqlBaseWalkerPre-process the from clause input tree.
-
isFilter
public boolean isFilter()
-
getCollectionFilterRole
public String getCollectionFilterRole()
-
isInEntityGraph
public boolean isInEntityGraph()
-
getSessionFactoryHelper
public SessionFactoryHelper getSessionFactoryHelper()
-
getTokenReplacements
public Map getTokenReplacements()
-
getAliasGenerator
public AliasGenerator getAliasGenerator()
-
getCurrentFromClause
public FromClause getCurrentFromClause()
-
getParseErrorHandler
public ParseErrorHandler getParseErrorHandler()
-
reportError
public void reportError(antlr.RecognitionException e)
- 指定者:
reportError在接口中ErrorReporter- 覆盖:
reportError在类中antlr.TreeParser
-
reportError
public void reportError(String s)
- 指定者:
reportError在接口中ErrorReporter- 覆盖:
reportError在类中antlr.TreeParser
-
reportWarning
public void reportWarning(String s)
- 指定者:
reportWarning在接口中ErrorReporter- 覆盖:
reportWarning在类中antlr.TreeParser
-
getQuerySpaces
public Set<Serializable> getQuerySpaces()
Returns the set of unique query spaces (a.k.a. table names) that occurred in the query.- 返回:
- A set of table names (Strings).
-
createFromElement
protected antlr.collections.AST createFromElement(String path, antlr.collections.AST alias, antlr.collections.AST propertyFetch) throws antlr.SemanticException
- 覆盖:
createFromElement在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
createFromFilterElement
protected antlr.collections.AST createFromFilterElement(antlr.collections.AST filterEntity, antlr.collections.AST alias) throws antlr.SemanticException- 覆盖:
createFromFilterElement在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
createFromJoinElement
protected void createFromJoinElement(antlr.collections.AST path, antlr.collections.AST alias, int joinType, antlr.collections.AST fetchNode, antlr.collections.AST propertyFetch, antlr.collections.AST with) throws antlr.SemanticException- 覆盖:
createFromJoinElement在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
finishFromClause
protected void finishFromClause(antlr.collections.AST fromClause) throws antlr.SemanticException- 覆盖:
finishFromClause在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
pushFromClause
protected void pushFromClause(antlr.collections.AST fromNode, antlr.collections.AST inputFromNode)Sets the current 'FROM' context.- 覆盖:
pushFromClause在类中HqlSqlBaseWalker- 参数:
fromNode- The new 'FROM' context.inputFromNode- The from node from the input AST.
-
lookupAlias
protected void lookupAlias(antlr.collections.AST aliasRef) throws antlr.SemanticException- 覆盖:
lookupAlias在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
setImpliedJoinType
protected void setImpliedJoinType(int joinType)
- 覆盖:
setImpliedJoinType在类中HqlSqlBaseWalker
-
getImpliedJoinType
public JoinType getImpliedJoinType()
-
lookupProperty
protected antlr.collections.AST lookupProperty(antlr.collections.AST dot, boolean root, boolean inSelect) throws antlr.SemanticException- 覆盖:
lookupProperty在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
isNonQualifiedPropertyRef
protected boolean isNonQualifiedPropertyRef(antlr.collections.AST ident)
-
lookupNonQualifiedProperty
protected antlr.collections.AST lookupNonQualifiedProperty(antlr.collections.AST property) throws antlr.SemanticException- 覆盖:
lookupNonQualifiedProperty在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processQuery
protected void processQuery(antlr.collections.AST select, antlr.collections.AST query) throws antlr.SemanticException- 覆盖:
processQuery在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
postProcessDML
protected void postProcessDML(RestrictableStatement statement) throws antlr.SemanticException
- 抛出:
antlr.SemanticException
-
postProcessUpdate
protected void postProcessUpdate(antlr.collections.AST update) throws antlr.SemanticException- 覆盖:
postProcessUpdate在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
postProcessDelete
protected void postProcessDelete(antlr.collections.AST delete) throws antlr.SemanticException- 覆盖:
postProcessDelete在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
postProcessInsert
protected void postProcessInsert(antlr.collections.AST insert) throws antlr.SemanticException, QueryException- 覆盖:
postProcessInsert在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticExceptionQueryException
-
resolve
protected void resolve(antlr.collections.AST node) throws antlr.SemanticException- 覆盖:
resolve在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
resolve
protected void resolve(antlr.collections.AST node, antlr.collections.AST predicateNode) throws antlr.SemanticException- 覆盖:
resolve在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
resolveSelectExpression
protected void resolveSelectExpression(antlr.collections.AST node) throws antlr.SemanticException- 覆盖:
resolveSelectExpression在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
beforeSelectClause
protected void beforeSelectClause() throws antlr.SemanticException- 覆盖:
beforeSelectClause在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
generatePositionalParameter
protected antlr.collections.AST generatePositionalParameter(antlr.collections.AST delimiterNode, antlr.collections.AST numberNode) throws antlr.SemanticException- 覆盖:
generatePositionalParameter在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
generateNamedParameter
protected antlr.collections.AST generateNamedParameter(antlr.collections.AST delimiterNode, antlr.collections.AST nameNode) throws antlr.SemanticException- 覆盖:
generateNamedParameter在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processConstant
protected void processConstant(antlr.collections.AST constant) throws antlr.SemanticException- 覆盖:
processConstant在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processBoolean
protected void processBoolean(antlr.collections.AST constant) throws antlr.SemanticException- 覆盖:
processBoolean在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processNumericLiteral
protected void processNumericLiteral(antlr.collections.AST literal)
-
processIndex
protected void processIndex(antlr.collections.AST indexOp) throws antlr.SemanticException- 覆盖:
processIndex在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processFunction
protected void processFunction(antlr.collections.AST functionCall, boolean inSelect) throws antlr.SemanticException- 覆盖:
processFunction在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processCastFunction
protected void processCastFunction(antlr.collections.AST castFunctionCall, boolean inSelect) throws antlr.SemanticException- 覆盖:
processCastFunction在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processAggregation
protected void processAggregation(antlr.collections.AST node, boolean inSelect) throws antlr.SemanticException- 覆盖:
processAggregation在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
processConstructor
protected void processConstructor(antlr.collections.AST constructor) throws antlr.SemanticException- 覆盖:
processConstructor在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
setAlias
protected void setAlias(antlr.collections.AST selectExpr, antlr.collections.AST ident)- 覆盖:
setAlias在类中HqlSqlBaseWalker
-
isOrderExpressionResultVariableRef
protected boolean isOrderExpressionResultVariableRef(antlr.collections.AST orderExpressionNode) throws antlr.SemanticException- 覆盖:
isOrderExpressionResultVariableRef在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
isGroupExpressionResultVariableRef
protected boolean isGroupExpressionResultVariableRef(antlr.collections.AST groupExpressionNode) throws antlr.SemanticException- 覆盖:
isGroupExpressionResultVariableRef在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
handleResultVariableRef
protected void handleResultVariableRef(antlr.collections.AST resultVariableRef) throws antlr.SemanticException- 覆盖:
handleResultVariableRef在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
getNamedParameterLocations
public int[] getNamedParameterLocations(String name) throws QueryException
Returns the locations of all occurrences of the named parameter.- 指定者:
getNamedParameterLocations在接口中ParameterBinder.NamedParameterSource- 参数:
name- The parameter name- 返回:
- The locations
- 抛出:
QueryException
-
addQuerySpaces
public void addQuerySpaces(Serializable[] spaces)
-
getReturnTypes
public Type[] getReturnTypes()
-
getReturnAliases
public String[] getReturnAliases()
-
getSelectClause
public SelectClause getSelectClause()
-
getFinalFromClause
public FromClause getFinalFromClause()
-
isShallowQuery
public boolean isShallowQuery()
-
getEnabledFilters
public Map getEnabledFilters()
-
getLiteralProcessor
public LiteralProcessor getLiteralProcessor()
-
getASTPrinter
public ASTPrinter getASTPrinter()
-
getParameterSpecs
public ArrayList<ParameterSpecification> getParameterSpecs()
-
getNumberOfParametersInSetClause
public int getNumberOfParametersInSetClause()
-
evaluateAssignment
protected void evaluateAssignment(antlr.collections.AST eq) throws antlr.SemanticException- 覆盖:
evaluateAssignment在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
getAssignmentSpecifications
public ArrayList getAssignmentSpecifications()
-
createIntoClause
protected antlr.collections.AST createIntoClause(String path, antlr.collections.AST propertySpec) throws antlr.SemanticException
- 覆盖:
createIntoClause在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
prepareVersioned
protected void prepareVersioned(antlr.collections.AST updateNode, antlr.collections.AST versioned) throws antlr.SemanticException- 覆盖:
prepareVersioned在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
prepareLogicOperator
protected void prepareLogicOperator(antlr.collections.AST operator) throws antlr.SemanticException- 覆盖:
prepareLogicOperator在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
prepareArithmeticOperator
protected void prepareArithmeticOperator(antlr.collections.AST operator) throws antlr.SemanticException- 覆盖:
prepareArithmeticOperator在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
validateMapPropertyExpression
protected void validateMapPropertyExpression(antlr.collections.AST node) throws antlr.SemanticException- 覆盖:
validateMapPropertyExpression在类中HqlSqlBaseWalker- 抛出:
antlr.SemanticException
-
getDialect
public Dialect getDialect()
-
panic
public static void panic()
-
-