Class AbstractSqlAstTranslator<T extends JdbcOperation>

    • Method Detail

      • getDialect

        public Dialect getDialect()
      • getSql

        public String getSql()
      • cleanup

        protected void cleanup()
      • getSqlAppender

        protected SqlAppender getSqlAppender()
      • getAffectedTableNames

        public Set<String> getAffectedTableNames()
        Description copied from interface: SqlAstTranslator
        Not the best spot for this. Its the table names collected while walking the SQL AST. Its ok here because the translator is consider a one-time-use. It just needs to be called after translation. A better option is probably to have "translation" objects that expose the affected table-names.
        Specified by:
        getAffectedTableNames in interface SqlAstTranslator<T extends JdbcOperation>
      • getDmlTargetTableAlias

        protected String getDmlTargetTableAlias()
      • getStatement

        protected Statement getStatement()
      • addAdditionalWherePredicate

        protected void addAdditionalWherePredicate​(Predicate predicate)
      • appendSql

        public void appendSql​(String fragment)
        Description copied from interface: SqlAppender
        Add the passed fragment into the in-flight buffer
        Specified by:
        appendSql in interface SqlAppender
      • appendSql

        public void appendSql​(char fragment)
        Specified by:
        appendSql in interface SqlAppender
      • appendSql

        public void appendSql​(int value)
        Specified by:
        appendSql in interface SqlAppender
      • appendSql

        public void appendSql​(long value)
        Specified by:
        appendSql in interface SqlAppender
      • appendSql

        public void appendSql​(boolean value)
        Specified by:
        appendSql in interface SqlAppender
      • getJdbcServices

        protected JdbcServices getJdbcServices()
      • getLockOptions

        protected LockOptions getLockOptions()
      • getLimit

        protected Limit getLimit()
      • hasLimit

        protected boolean hasLimit()
      • hasOffset

        protected boolean hasOffset​(QueryPart queryPart)
      • useOffsetFetchClause

        protected boolean useOffsetFetchClause​(QueryPart queryPart)
      • isRowsOnlyFetchClauseType

        protected boolean isRowsOnlyFetchClauseType​(QueryPart queryPart)
      • getOffsetParameter

        protected JdbcParameter getOffsetParameter()
      • setOffsetParameter

        protected void setOffsetParameter​(JdbcParameter offsetParameter)
      • getLimitParameter

        protected JdbcParameter getLimitParameter()
      • setLimitParameter

        protected void setLimitParameter​(JdbcParameter limitParameter)
      • inOverOrWithinGroupClause

        protected boolean inOverOrWithinGroupClause()
      • getClauseStack

        protected Stack<Clause> getClauseStack()
      • getCurrentCteStatement

        protected CteStatement getCurrentCteStatement()
      • needsRowsToSkip

        protected boolean needsRowsToSkip()
      • needsMaxRows

        protected boolean needsMaxRows()
      • prepareLimitOffsetParameters

        protected void prepareLimitOffsetParameters()
      • visitDeleteStatementOnly

        protected void visitDeleteStatementOnly​(DeleteStatement statement)
      • visitUpdateStatementOnly

        protected void visitUpdateStatementOnly​(UpdateStatement statement)
      • visitSetAssignment

        protected void visitSetAssignment​(Assignment assignment)
      • visitInsertStatementOnly

        protected void visitInsertStatementOnly​(InsertSelectStatement statement)
      • visitValuesList

        protected void visitValuesList​(List<Values> valuesList)
      • visitForUpdateClause

        protected void visitForUpdateClause​(QuerySpec querySpec)
      • getForUpdate

        protected String getForUpdate()
      • getForShare

        protected String getForShare​(int timeoutMillis)
      • getForUpdateWithClause

        protected String getForUpdateWithClause()
      • getNoWait

        protected String getNoWait()
      • getSkipLocked

        protected String getSkipLocked()
      • getEffectiveLockMode

        protected LockMode getEffectiveLockMode​(String alias)
      • getEffectiveLockTimeout

        protected int getEffectiveLockTimeout​(LockMode lockMode)
      • hasAggregateFunctions

        protected boolean hasAggregateFunctions​(QuerySpec querySpec)
      • visitReturningColumns

        protected void visitReturningColumns​(List<ColumnReference> returningColumns)
      • visitCteContainer

        public void visitCteContainer​(CteContainer cteContainer)
      • renderCteColumns

        protected void renderCteColumns​(CteStatement cte)
      • determineCyclePathColumnName

        protected String determineCyclePathColumnName​(CteStatement cte)
      • isInRecursiveQueryPart

        protected boolean isInRecursiveQueryPart()
      • visitCteDefinition

        protected void visitCteDefinition​(CteStatement cte)
      • supportsWithClause

        protected boolean supportsWithClause()
        Whether the SQL with clause is supported.
      • supportsNestedWithClause

        protected boolean supportsNestedWithClause()
        Whether the SQL with clause is supported within a CTE.
      • supportsWithClauseInSubquery

        protected boolean supportsWithClauseInSubquery()
        Whether the SQL with clause is supported within a subquery.
      • needsCteInlining

        protected boolean needsCteInlining()
        Whether CTEs should be inlined rather than rendered as CTEs.
      • shouldInlineCte

        protected boolean shouldInlineCte​(TableGroup tableGroup)
        Whether CTEs should be inlined rather than rendered as CTEs.
      • needsRecursiveKeywordInWithClause

        protected boolean needsRecursiveKeywordInWithClause()
        Whether the SQL with clause requires the "recursive" keyword for recursive CTEs.
      • supportsRecursiveSearchClause

        protected boolean supportsRecursiveSearchClause()
        Whether the SQL search clause is supported, which can be used for recursive CTEs.
      • supportsRecursiveCycleClause

        protected boolean supportsRecursiveCycleClause()
        Whether the SQL cycle clause is supported, which can be used for recursive CTEs.
      • supportsRecursiveCycleUsingClause

        protected boolean supportsRecursiveCycleUsingClause()
        Whether the SQL cycle clause supports the using sub-clause.
      • supportsRecursiveClauseArrayAndRowEmulation

        protected boolean supportsRecursiveClauseArrayAndRowEmulation()
        Whether the recursive search and cycle clause emulations based on the array and row constructor is supported.
      • supportsRowConstructor

        protected boolean supportsRowConstructor()
        Whether the SQL row constructor is supported.
      • supportsArrayConstructor

        protected boolean supportsArrayConstructor()
        Whether the SQL array constructor is supported.
      • renderMaterializationHint

        protected void renderMaterializationHint​(CteMaterialization materialization)
      • renderSearchClause

        protected void renderSearchClause​(CteStatement cte)
      • renderStandardSearchClause

        protected void renderStandardSearchClause​(CteStatement cte)
      • renderCycleClause

        protected void renderCycleClause​(CteStatement cte)
      • renderStandardCycleClause

        protected void renderStandardCycleClause​(CteStatement cte)
      • renderRecursiveCteVirtualSelections

        protected void renderRecursiveCteVirtualSelections​(SelectClause selectClause)
      • emulateSearchClauseOrderWithRowAndArray

        protected void emulateSearchClauseOrderWithRowAndArray​(SelectClause selectClause)
      • visitRecursivePath

        protected void visitRecursivePath​(Expression recursivePath,
                                          int sizeEstimate)
        Renders the recursive path, possibly wrapping a cast expression around it, to make sure a type with proper size is chosen.
      • emulateCycleClauseWithRowAndArray

        protected void emulateCycleClauseWithRowAndArray​(SelectClause selectClause)
      • getArrayContainsFunction

        protected String getArrayContainsFunction()
        Returns the name of the array_contains(array, element) function, which is used for emulating the cycle clause.
      • castNumberToString

        protected Expression castNumberToString​(Expression expression,
                                                int precision,
                                                int scale)
        Casts a number expression to a string with the given precision and scale.
      • renderQueryGroup

        protected void renderQueryGroup​(QueryGroup queryGroup,
                                        boolean renderOrderByAndOffsetFetchClause)
      • supportsSimpleQueryGrouping

        protected boolean supportsSimpleQueryGrouping()
      • supportsDuplicateSelectItemsInQueryGroup

        protected boolean supportsDuplicateSelectItemsInQueryGroup()
      • visitWhereClause

        protected final void visitWhereClause​(Predicate whereClauseRestrictions)
      • resolveAliasedExpression

        protected Expression resolveAliasedExpression​(Expression expression)
      • resolveExpressionToAlias

        protected Expression resolveExpressionToAlias​(Expression expression)
      • visitPartitionByClause

        protected final void visitPartitionByClause​(List<Expression> partitionExpressions)
      • visitPartitionExpressions

        protected final void visitPartitionExpressions​(List<Expression> partitionExpressions,
                                                       Function<Expression,​Expression> resolveAliasExpression,
                                                       boolean inlineParametersOfAliasedExpressions)
      • renderPartitionItem

        protected void renderPartitionItem​(Expression expression)
      • visitHavingClause

        protected final void visitHavingClause​(QuerySpec querySpec)
      • renderOrderBy

        protected void renderOrderBy​(boolean addWhitespace,
                                     List<SortSpecification> sortSpecifications)
      • emulateTupleComparison

        protected void emulateTupleComparison​(List<? extends SqlAstNode> lhsExpressions,
                                              List<? extends SqlAstNode> rhsExpressions,
                                              ComparisonOperator operator,
                                              boolean indexOptimized)
        A tuple comparison like (a, b) > (1, 2) can be emulated through it logical definition: a > 1 or a = 1 and b > 2. The normal tuple comparison emulation is not very index friendly though because of the top level OR predicate. Index optimized emulation of tuple comparisons puts an AND predicate on the top level. The effect of that is, that the database can do an index seek to efficiently find a superset of matching rows. Generally, it is sufficient to just add a broader predicate like for (a, b) > (1, 2) we add a >= 1 and (..). But we can further optimize this if we just remove the non-matching parts from this too broad predicate. For (a, b, c) > (1, 2, 3) we use the broad predicate a >= 1 and then want to remove rows where a = 1 and (b, c) <= (2, 3)
      • supportsIntersect

        protected boolean supportsIntersect()
      • supportsNestedSubqueryCorrelation

        protected boolean supportsNestedSubqueryCorrelation()
      • renderExpressionsAsSubquery

        protected void renderExpressionsAsSubquery​(List<? extends Expression> expressions)
      • supportsNullPrecedence

        protected boolean supportsNullPrecedence()
      • emulateSortSpecificationNullPrecedence

        protected void emulateSortSpecificationNullPrecedence​(Expression sortExpression,
                                                              NullPrecedence nullPrecedence)
      • renderOffsetFetchClause

        protected void renderOffsetFetchClause​(QueryPart queryPart,
                                               boolean renderOffsetRowsKeyword)
      • renderOffsetFetchClause

        protected void renderOffsetFetchClause​(Expression offsetExpression,
                                               Expression fetchExpression,
                                               FetchClauseType fetchClauseType,
                                               boolean renderOffsetRowsKeyword)
      • renderOffset

        protected void renderOffset​(Expression offsetExpression,
                                    boolean renderOffsetRowsKeyword)
      • renderOffsetExpression

        protected void renderOffsetExpression​(Expression offsetExpression)
      • renderFetchExpression

        protected void renderFetchExpression​(Expression fetchExpression)
      • renderTopClause

        protected void renderTopClause​(QuerySpec querySpec,
                                       boolean addOffset,
                                       boolean needsParenthesis)
      • renderTopClause

        protected void renderTopClause​(Expression offsetExpression,
                                       Expression fetchExpression,
                                       FetchClauseType fetchClauseType,
                                       boolean addOffset,
                                       boolean needsParenthesis)
      • renderTopStartAtClause

        protected void renderTopStartAtClause​(QuerySpec querySpec)
      • renderRowsToClause

        protected void renderRowsToClause​(QuerySpec querySpec)
      • renderRowsToClause

        protected void renderRowsToClause​(Expression offsetClauseExpression,
                                          Expression fetchClauseExpression)
      • renderFetchPlusOffsetExpression

        protected void renderFetchPlusOffsetExpression​(Expression fetchClauseExpression,
                                                       Expression offsetClauseExpression,
                                                       int offset)
      • renderFetchPlusOffsetExpressionAsLiteral

        protected void renderFetchPlusOffsetExpressionAsLiteral​(Expression fetchClauseExpression,
                                                                Expression offsetClauseExpression,
                                                                int offset)
      • renderFetchPlusOffsetExpressionAsSingleParameter

        protected void renderFetchPlusOffsetExpressionAsSingleParameter​(Expression fetchClauseExpression,
                                                                        Expression offsetClauseExpression,
                                                                        int offset)
      • renderFirstSkipClause

        protected void renderFirstSkipClause​(QuerySpec querySpec)
      • renderFirstSkipClause

        protected void renderFirstSkipClause​(Expression offsetExpression,
                                             Expression fetchExpression)
      • renderSkipFirstClause

        protected void renderSkipFirstClause​(QuerySpec querySpec)
      • renderSkipFirstClause

        protected void renderSkipFirstClause​(Expression offsetExpression,
                                             Expression fetchExpression)
      • renderFirstClause

        protected void renderFirstClause​(QuerySpec querySpec)
      • renderFirstClause

        protected void renderFirstClause​(Expression offsetExpression,
                                         Expression fetchExpression)
      • renderCombinedLimitClause

        protected void renderCombinedLimitClause​(QueryPart queryPart)
      • renderCombinedLimitClause

        protected void renderCombinedLimitClause​(Expression offsetExpression,
                                                 Expression fetchExpression)
      • renderLimitOffsetClause

        protected void renderLimitOffsetClause​(QueryPart queryPart)
      • renderLimitOffsetClause

        protected void renderLimitOffsetClause​(Expression offsetExpression,
                                               Expression fetchExpression)
      • assertRowsOnlyFetchClauseType

        protected void assertRowsOnlyFetchClauseType​(QueryPart queryPart)
      • getQueryPartForRowNumbering

        protected QueryPart getQueryPartForRowNumbering()
      • isRowNumberingCurrentQueryPart

        protected boolean isRowNumberingCurrentQueryPart()
      • emulateFetchOffsetWithWindowFunctions

        protected void emulateFetchOffsetWithWindowFunctions​(QueryPart queryPart,
                                                             boolean emulateFetchClause)
      • emulateFetchOffsetWithWindowFunctions

        protected void emulateFetchOffsetWithWindowFunctions​(QueryPart queryPart,
                                                             Expression offsetExpression,
                                                             Expression fetchExpression,
                                                             FetchClauseType fetchClauseType,
                                                             boolean emulateFetchClause)
      • emulateFetchOffsetWithWindowFunctionsVisitQueryPart

        protected void emulateFetchOffsetWithWindowFunctionsVisitQueryPart​(QueryPart queryPart)
      • withRowNumbering

        protected final void withRowNumbering​(QueryPart queryPart,
                                              boolean needsSelectAliases,
                                              Runnable r)
      • visitSqlSelections

        protected void visitSqlSelections​(SelectClause selectClause)
      • renderVirtualSelections

        protected void renderVirtualSelections​(SelectClause selectClause)
      • renderRowNumberingSelectItems

        protected void renderRowNumberingSelectItems​(SelectClause selectClause,
                                                     QueryPart queryPart)
      • getFetchClauseTypeForRowNumbering

        protected FetchClauseType getFetchClauseTypeForRowNumbering​(QueryPart queryPartForRowNumbering)
      • isParameter

        protected final boolean isParameter​(Expression expression)
      • isLiteral

        protected final boolean isLiteral​(Expression expression)
      • visitSqlSelectExpression

        protected void visitSqlSelectExpression​(Expression expression)
      • renderSelectExpression

        protected void renderSelectExpression​(Expression expression)
      • renderExpressionAsClauseItem

        protected void renderExpressionAsClauseItem​(Expression expression)
      • renderSelectExpressionWithCastedOrInlinedPlainParameters

        protected void renderSelectExpressionWithCastedOrInlinedPlainParameters​(Expression expression)
      • renderCasted

        protected void renderCasted​(Expression expression)
      • renderLiteral

        protected void renderLiteral​(Literal literal,
                                     boolean castParameter)
      • hasNestedTableGroupsToRender

        protected boolean hasNestedTableGroupsToRender​(List<TableGroupJoin> nestedTableGroupJoins)
      • renderPrimaryTableReference

        protected boolean renderPrimaryTableReference​(TableGroup tableGroup,
                                                      LockMode lockMode)
      • inlineCteTableGroup

        protected void inlineCteTableGroup​(TableGroup tableGroup,
                                           LockMode lockMode)
      • isCorrelated

        protected boolean isCorrelated​(CteStatement cteStatement)
      • emulateQueryPartTableReferenceColumnAliasing

        protected void emulateQueryPartTableReferenceColumnAliasing​(QueryPartTableReference tableReference)
      • emulateValuesTableReferenceColumnAliasing

        protected void emulateValuesTableReferenceColumnAliasing​(ValuesTableReference tableReference)
      • renderDerivedTableReference

        protected void renderDerivedTableReference​(DerivedTableReference tableReference)
      • renderTableReferenceIdentificationVariable

        protected final void renderTableReferenceIdentificationVariable​(TableReference tableReference)
      • rendersTableReferenceAlias

        public static boolean rendersTableReferenceAlias​(Clause clause)
      • registerAffectedTable

        protected void registerAffectedTable​(NamedTableReference tableReference)
      • registerAffectedTable

        protected void registerAffectedTable​(String tableExpression)
      • renderTableReferenceJoins

        protected void renderTableReferenceJoins​(TableGroup tableGroup)
      • processTableGroupJoins

        protected void processTableGroupJoins​(TableGroup source)
      • processNestedTableGroupJoins

        protected void processNestedTableGroupJoins​(TableGroup source,
                                                    List<TableGroupJoin> tableGroupJoinCollector)
      • determineLateralEmulationPredicate

        protected Predicate determineLateralEmulationPredicate​(TableGroup tableGroup)
      • shouldEmulateLateralWithIntersect

        protected boolean shouldEmulateLateralWithIntersect​(QueryPart queryPart)
      • renderCommaSeparated

        protected final void renderCommaSeparated​(Iterable<? extends SqlAstNode> expressions)
      • renderCommaSeparatedSelectExpression

        protected final void renderCommaSeparatedSelectExpression​(Iterable<? extends SqlAstNode> expressions)
      • renderCommaSeparatedSelectExpression

        protected final void renderCommaSeparatedSelectExpression​(Iterable<? extends SqlAstNode> expressions,
                                                                  Iterable<String> aliases)
      • visitCaseSearchedExpression

        protected void visitCaseSearchedExpression​(CaseSearchedExpression caseSearchedExpression,
                                                   boolean inSelect)
      • visitDecodeCaseSearchedExpression

        protected void visitDecodeCaseSearchedExpression​(CaseSearchedExpression caseSearchedExpression)
      • visitCaseSimpleExpression

        protected void visitCaseSimpleExpression​(CaseSimpleExpression caseSimpleExpression,
                                                 boolean inSelect)
      • areAllResultsParameters

        protected boolean areAllResultsParameters​(CaseSearchedExpression caseSearchedExpression)
      • areAllResultsParameters

        protected boolean areAllResultsParameters​(CaseSimpleExpression caseSimpleExpression)
      • renderAsLiteral

        protected void renderAsLiteral​(JdbcParameter jdbcParameter,
                                       Object literalValue)
      • emulateQuantifiedTupleSubQueryPredicate

        protected void emulateQuantifiedTupleSubQueryPredicate​(Predicate predicate,
                                                               SelectStatement selectStatement,
                                                               SqlTuple lhsTuple,
                                                               ComparisonOperator tupleComparisonOperator)
        An optimized emulation for relational tuple sub-query comparisons. The idea of this method is to use limit 1 to select the max or min tuple and only compare against that.
      • renderCaseInsensitiveLikeEmulation

        protected void renderCaseInsensitiveLikeEmulation​(Expression lhs,
                                                          Expression rhs,
                                                          Expression escapeCharacter,
                                                          boolean negated)
      • renderBackslashEscapedLikePattern

        protected void renderBackslashEscapedLikePattern​(Expression pattern,
                                                         Expression escapeCharacter,
                                                         boolean noBackslashEscapes)
      • appendBackslashEscapedLikeLiteral

        protected void appendBackslashEscapedLikeLiteral​(SqlAppender appender,
                                                         String literal,
                                                         boolean noBackslashEscapes)
      • supportsQuantifiedPredicates

        protected boolean supportsQuantifiedPredicates()
        Is this dialect known to support quantified predicates.

        Basically, does it support syntax like "... where FIRST_NAME > ALL (select ...) ...".

        Returns:
        True if this SQL dialect is known to support quantified predicates; false otherwise.
      • supportsDistinctFromPredicate

        protected boolean supportsDistinctFromPredicate()
        Is this SQL dialect known to support some kind of distinct from predicate.

        Basically, does it support syntax like "... where FIRST_NAME IS DISTINCT FROM LAST_NAME"

        Returns:
        True if this SQL dialect is known to support some kind of distinct from predicate; false otherwise
      • supportsRowValueConstructorSyntax

        protected boolean supportsRowValueConstructorSyntax()
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax.

        Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax; false otherwise.
      • supportsRowValueConstructorGtLtSyntax

        protected boolean supportsRowValueConstructorGtLtSyntax()
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax with <, >, and operators.

        Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) < ('Steve', 'Ebersole') ...".

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax with relational comparison operators; false otherwise.
      • supportsRowValueConstructorDistinctFromSyntax

        protected boolean supportsRowValueConstructorDistinctFromSyntax()
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax with is distinct from and is not distinct from operators.

        Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) is distinct from ('Steve', 'Ebersole') ...".

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax with distinct from comparison operators; false otherwise.
      • supportsRowValueConstructorSyntaxInSet

        protected boolean supportsRowValueConstructorSyntaxInSet()
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax, sometimes called tuple syntax, in the SET clause;

        Basically, does it support syntax like "... SET (FIRST_NAME, LAST_NAME) = ('Steve', 'Ebersole') ...".

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax in the SET clause; false otherwise.
      • supportsRowValueConstructorSyntaxInQuantifiedPredicates

        protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates()
        Is this dialect known to support what ANSI-SQL terms "row value constructor" syntax; sometimes called tuple syntax with quantified predicates.

        Basically, does it support syntax like "... where (FIRST_NAME, LAST_NAME) = ALL (select ...) ...".

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax with quantified predicates; false otherwise.
      • supportsRowValueConstructorSyntaxInInList

        protected boolean supportsRowValueConstructorSyntaxInInList()
        If the dialect supports row values, does it offer such support in IN lists as well?

        For example, "... where (FIRST_NAME, LAST_NAME) IN ( (?, ?), (?, ?) ) ..."

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax in the IN list; false otherwise.
      • supportsRowValueConstructorSyntaxInInSubQuery

        protected boolean supportsRowValueConstructorSyntaxInInSubQuery()
        If the dialect supports row values, does it offer such support in IN subqueries as well?

        For example, "... where (FIRST_NAME, LAST_NAME) IN ( select ... ) ..."

        Returns:
        True if this SQL dialect is known to support "row value constructor" syntax in the IN subqueries; false otherwise.
      • getFromDual

        protected String getFromDual()
        Some databases require a bit of syntactic noise when there are no tables in the from clause.
        Returns:
        the SQL equivalent to Oracle's from dual.
      • getFromDualForSelectOnly

        protected String getFromDualForSelectOnly()
      • renderIntoIntoAndTable

        protected void renderIntoIntoAndTable​(TableInsertStandard tableInsert)
        Renders the insert into <table name> portion of an insert
      • renderInsertIntoNoColumns

        protected void renderInsertIntoNoColumns​(TableInsertStandard tableInsert)
        Handle rendering an insert with no columns