Top Description Inners Fields Constructors Methods
org.hibernate.hql.ast

public Class SqlGenerator

extends SqlGeneratorBase
implements ErrorReporter
Class Inheritance
All Implemented Interfaces
org.hibernate.hql.ast.ErrorReporter
Imports
java.util.ArrayList, .LinkedList, .List, .Arrays, antlr.RecognitionException, antlr.collections.AST, org.hibernate.QueryException, org.hibernate.hql.ast.tree.FunctionNode, .FromElement, .Node, .ParameterNode, .ParameterContainer, org.hibernate.type.Type, org.hibernate.util.StringHelper, org.hibernate.param.ParameterSpecification, org.hibernate.dialect.function.SQLFunction, org.hibernate.engine.SessionFactoryImplementor, org.hibernate.hql.antlr.SqlGeneratorBase, .SqlTokenTypes, org.hibernate.hql.ast.util.ASTPrinter, org.slf4j.Logger, .LoggerFactory

Generates SQL by overriding callback methods in the base class, which does the actual SQL AST walking.
Authors
Joshua Davis, Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
SqlGenerator.DefaultWriter

The default SQL writer.

pack-priv class
SqlGenerator.FunctionArguments

SQL function processing code redirects generated SQL output to an instance of this class which catches function arguments.

pack-priv static interface
SqlGenerator.SqlWriter

Writes SQL fragments.

Field Summary

Modifier and TypeField and Description
private List<E>
private static final Logger
private LinkedList<SqlGenerator.SqlWriter>
private ParseErrorHandler
private final ASTPrinter
public static boolean
private SessionFactoryImplementor
private final boolean
private int
private SqlGenerator.SqlWriter
writer

all append invocations on the buf should go through this Output instance variable.

Inherited from org.hibernate.hql.antlr.SqlGeneratorBase:
_tokenNames_tokenSet_0_tokenSet_1_tokenSet_2_tokenSet_3_tokenSet_4_tokenSet_5

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
private String
protected void
protected void
protected void
public List<E>
public ParseErrorHandler
public String
protected void
protected void
optionalSpace()

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.optionalSpace.

Add a aspace if the previous token was not a space or a parenthesis.
protected void
protected void
public static void
public void
reportError(RecognitionException e)

Overrides antlr.TreeParser.reportError.

Implements org.hibernate.hql.ast.ErrorReporter.reportError.

Parser error-reporting function can be overridden in subclass
public void
reportError(String s)

Overrides antlr.TreeParser.reportError.

Implements org.hibernate.hql.ast.ErrorReporter.reportError.

Parser error-reporting function can be overridden in subclass
public void
reportWarning(String s)

Overrides antlr.TreeParser.reportWarning.

Implements org.hibernate.hql.ast.ErrorReporter.reportWarning.

Parser warning-reporting function can be overridden in subclass
public void
traceIn(String ruleName, AST tree)

Overrides antlr.TreeParser.traceIn.

public void
traceOut(String ruleName, AST tree)

Overrides antlr.TreeParser.traceOut.

private void
Inherited from org.hibernate.hql.antlr.SqlGeneratorBase:
additiveExpraddrExpraggregateargumentsarithmeticExprbinaryComparisonExpressionbooleanExprbooleanOpcaseExprcomparisonExprconditionListconstantcountcountExprdeleteStatementdistinctOrAllexoticComparisonExpressionexprfiltersfromfromTablegetLastChargetStringBuffergroupExprshasTextinListinsertStatementlikeEscapemapComponentReferencemethodCallmultiplicativeExprnestedExprnestedExprAfterMinusDivnyiorderDirectionorderExprsparameterparenSelectquantifiedselectAtomselectClauseselectColumnselectExprselectStatementseparatorsetClausesimpleExprsimpleExprListsqlTokenstatementtableJointhetaJoinsupdateStatementwhereClausewhereClauseExprwhereExpr

Field Detail

collectedParametersback to summary
private List<E> collectedParameters
logback to summary
private static final Logger log

Hides org.hibernate.hql.antlr.SqlGeneratorBase.log.

outputStackback to summary
private LinkedList<SqlGenerator.SqlWriter> outputStack
parseErrorHandlerback to summary
private ParseErrorHandler parseErrorHandler
printerback to summary
private final ASTPrinter printer
REGRESSION_STYLE_CROSS_JOINSback to summary
public static boolean REGRESSION_STYLE_CROSS_JOINS
sessionFactoryback to summary
private SessionFactoryImplementor sessionFactory
traceback to summary
private final boolean trace
traceDepthback to summary
private int traceDepth

Hides antlr.TreeParser.traceDepth.

writerback to summary
private SqlGenerator.SqlWriter writer

all append invocations on the buf should go through this Output instance variable. The value of this variable may be temporarily substituted by sql function processing code to catch generated arguments. This is because sql function templates need arguments as separate string chunks that will be assembled into the target dialect-specific function call.

Constructor Detail

SqlGeneratorback to summary
public SqlGenerator(SessionFactoryImplementor sfi)

Method Detail

beginFunctionTemplateback to summary
protected void beginFunctionTemplate(AST node, AST nameNode)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.beginFunctionTemplate.

buildTraceNodeNameback to summary
private String buildTraceNodeName(AST tree)
commaBetweenParametersback to summary
protected void commaBetweenParameters(String comma)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.commaBetweenParameters.

endFunctionTemplateback to summary
protected void endFunctionTemplate(AST node)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.endFunctionTemplate.

fromFragmentSeparatorback to summary
protected void fromFragmentSeparator(AST a)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.fromFragmentSeparator.

getCollectedParametersback to summary
public List<E> getCollectedParameters()
getParseErrorHandlerback to summary
public ParseErrorHandler getParseErrorHandler()
getSQLback to summary
public String getSQL()
nestedFromFragmentback to summary
protected void nestedFromFragment(AST d, AST parent)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.nestedFromFragment.

optionalSpaceback to summary
protected void optionalSpace()

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.optionalSpace.

Doc from org.hibernate.hql.antlr.SqlGeneratorBase.optionalSpace.

Add a aspace if the previous token was not a space or a parenthesis.

outback to summary
protected void out(String s)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.out.

outback to summary
protected void out(AST n)

Overrides org.hibernate.hql.antlr.SqlGeneratorBase.out.

panicback to summary
public static void panic()

Hides antlr.TreeParser.panic.

reportErrorback to summary
public void reportError(RecognitionException e)

Overrides antlr.TreeParser.reportError.

Implements org.hibernate.hql.ast.ErrorReporter.reportError.

Doc from antlr.TreeParser.reportError.

Parser error-reporting function can be overridden in subclass

reportErrorback to summary
public void reportError(String s)

Overrides antlr.TreeParser.reportError.

Implements org.hibernate.hql.ast.ErrorReporter.reportError.

Doc from antlr.TreeParser.reportError.

Parser error-reporting function can be overridden in subclass

reportWarningback to summary
public void reportWarning(String s)

Overrides antlr.TreeParser.reportWarning.

Implements org.hibernate.hql.ast.ErrorReporter.reportWarning.

Doc from antlr.TreeParser.reportWarning.

Parser warning-reporting function can be overridden in subclass

traceInback to summary
public void traceIn(String ruleName, AST tree)

Overrides antlr.TreeParser.traceIn.

traceOutback to summary
public void traceOut(String ruleName, AST tree)

Overrides antlr.TreeParser.traceOut.

writeCrossJoinSeparatorback to summary
private void writeCrossJoinSeparator()
org.hibernate.hql.ast back to summary

pack-priv Class SqlGenerator.DefaultWriter

extends Object
implements SqlWriter
Class Inheritance
All Implemented Interfaces
org.hibernate.hql.ast.SqlGenerator.SqlWriter

The default SQL writer.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
commaBetweenParameters(String
either " , " or ", "
comma
)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

todo remove this hack The parameter is either ", " or " , ".
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DefaultWriterback to summary
pack-priv DefaultWriter()

Method Detail

clauseback to summary
public void clause(String clause)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.clause.

commaBetweenParametersback to summary
public void commaBetweenParameters(String comma)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

Doc from org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

todo remove this hack The parameter is either ", " or " , ". This is needed to pass sql generating tests as the old sql generator uses " , " in the WHERE and ", " in SELECT.

Parameters
comma:String

either " , " or ", "

org.hibernate.hql.ast back to summary

pack-priv Class SqlGenerator.FunctionArguments

extends Object
implements SqlWriter
Class Inheritance
All Implemented Interfaces
org.hibernate.hql.ast.SqlGenerator.SqlWriter

SQL function processing code redirects generated SQL output to an instance of this class which catches function arguments.

Field Summary

Modifier and TypeField and Description
private int
private final List<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
commaBetweenParameters(String
either " , " or ", "
comma
)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

todo remove this hack The parameter is either ", " or " , ".
public List<E>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

argIndback to summary
private int argInd
argsback to summary
private final List<String> args

Constructor Detail

FunctionArgumentsback to summary
pack-priv FunctionArguments()

Method Detail

clauseback to summary
public void clause(String clause)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.clause.

commaBetweenParametersback to summary
public void commaBetweenParameters(String comma)

Implements org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

Doc from org.hibernate.hql.ast.SqlGenerator.SqlWriter.commaBetweenParameters.

todo remove this hack The parameter is either ", " or " , ". This is needed to pass sql generating tests as the old sql generator uses " , " in the WHERE and ", " in SELECT.

Parameters
comma:String

either " , " or ", "

getArgsback to summary
public List<E> getArgs()
org.hibernate.hql.ast back to summary

pack-priv Interface SqlGenerator.SqlWriter

Known Direct Implementers
org.hibernate.hql.ast.SqlGenerator.FunctionArguments, org.hibernate.hql.ast.SqlGenerator.DefaultWriter

Writes SQL fragments.

Method Summary

Modifier and TypeMethod and Description
public void
clause(String clause)

public void
commaBetweenParameters(String
either " , " or ", "
comma
)

todo remove this hack The parameter is either ", " or " , ".

Method Detail

clauseback to summary
public void clause(String clause)
commaBetweenParametersback to summary
public void commaBetweenParameters(String comma)

todo remove this hack The parameter is either ", " or " , ". This is needed to pass sql generating tests as the old sql generator uses " , " in the WHERE and ", " in SELECT.

Parameters
comma:String

either " , " or ", "