Interface SqlAstTranslator<T extends JdbcOperation>

All Superinterfaces:
SqlAstWalker
All Known Implementing Classes:
AbstractSqlAstTranslator, DB2SqlAstTranslator, PostgreSQLFamilySqlAstTranslator, PostgreSQLSqlAstTranslator, SqlAstTranslatorWithMerge, SqlAstTranslatorWithOnDuplicateKeyUpdate, SqlAstTranslatorWithUpsert, StandardSqlAstTranslator

@SPI({USE,IMPLEMENT,SUPPLY}) public interface SqlAstTranslator<T extends JdbcOperation> extends SqlAstWalker

Translates one [#getSqlAst SQL AST] and produces a JdbcOperation.

Translators are created by a SqlAstTranslatorFactory for a single translation and are not reusable. Extend AbstractSqlAstTranslator for custom SQL rendering. Implement this contract directly, normally on top of AbstractSqlAstWalker, when the JDBC driver uses a fundamentally different command language.

Direct implementations should create query operations with JdbcOperations. A SqlAstTranslationRequest.ModelMutation is not a query operation; create its result through TableMutation.createMutationOperation(String, List).

Since:
8.0
See Also:
  • Method Details

    • translate

      @SPI({IMPLEMENT,SUPPLY}) T translate(JdbcParameterBindings jdbcParameterBindings, QueryOptions queryOptions)
      Perform this translator's one translation.
      Parameters:
      jdbcParameterBindings - parameter values available for literalization and JDBC binding
      queryOptions - execution options which affect translation
      Returns:
      the JDBC operation produced from this translator's SQL AST
    • getSqlAst

      Statement getSqlAst()
      The SQL AST assigned to this translator.
    • getSessionFactory

      SessionFactoryImplementor getSessionFactory()
      The SessionFactory whose services are used during translation.
    • getLiteralValue

      <X> X getLiteralValue(Expression expression)
      Returns the literal value of the given expression, inlining a parameter value if necessary.
      Since:
      7.0
    • renderNamedSetReturningFunction

      @Incubating(since="6.0") @SPI(USE) void renderNamedSetReturningFunction(String functionName, List<? extends SqlAstNode> sqlAstArguments, SetReturningFunctionType tupleType, String tableIdentifierVariable, SqlAstNodeRenderingMode argumentRenderingMode)
      Renders a named set returning function.
      Since:
      7.0
    • render

      void render(SqlAstNode sqlAstNode, SqlAstNodeRenderingMode renderingMode)
      Render the given SQL AST node using the requested expression mode and the current translator context.
    • getCurrentQueryPart

      QueryPart getCurrentQueryPart()
      The query part at the top of the translator's traversal stack.
    • getCurrentClauseStack

      Stack<Clause> getCurrentClauseStack()
      Read-only access to the translator's current clause stack. Providers should inspect but not mutate this stack.
    • getAffectedTableNames

      Set<String> getAffectedTableNames()
      Not the best spot for this. Returns the table names collected while walking the SQL AST. It's 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.
    • addAffectedTableName

      void addAffectedTableName(String tableName)
      Register an affected physical table name while translating a mutation.