Interface SqlAugmentationListener


public interface SqlAugmentationListener
A concrete SqlAugmentationListener observes the creation of an SQL-script with the opportunity to apply changes/extensions.

Several callback methods allow influencing certain aspects of the SQL without changing the overall structure.

Examples:

  • Add a header or footer to each SQL script.
  • Change the join type for a particular critical table combination.
  • Extend the SQL so that it returns data for this selection of IDs instead.
  • Apply native hints.
Author:
Karl Eilebrecht
  • Method Details

    • handleBeforeScript

      default void handleBeforeScript(StringBuilder sb, SqlConversionProcessContext ctx)
      Called before starting the SQL-script
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
    • handleBeforeMainStatement

      default void handleBeforeMainStatement(StringBuilder sb, SqlConversionProcessContext ctx, boolean withClausePresent)
      Called before the main SELECT line
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      withClausePresent - true if there is already a WITH-section
    • handleAppendJoinType

      default void handleAppendJoinType(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo, String suggestedJoinType)
      The default implementation just appends the suggested join type e.g. "INNER JOIN" to the builder.
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      tableOrAliasFrom - name of the table or alias we are coming from
      tableOrAliasTo - name of the table or alias we are joining
      suggestedJoinType - e.g. "INNER JOIN" or "LEFT OUTER JOIN"
    • handleBeforeOnClause

      default void handleBeforeOnClause(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo)
      Called right before printing the text "ON"
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      tableOrAliasFrom - source table or alias
      tableOrAliasTo - table or alias to be joined
    • handleBeforeOnConditions

      default void handleBeforeOnConditions(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo)
      Called before printing an ON-condition, means right after the text "ON"
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      tableOrAliasFrom - source table or alias
      tableOrAliasTo - table or alias to be joined
    • handleAfterOnConditions

      default void handleAfterOnConditions(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo)
      Called after finishing the ON-part of a join
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      tableOrAliasFrom - source table or alias
      tableOrAliasTo - table or alias to be joined
    • handleAfterMainSelect

      default void handleAfterMainSelect(StringBuilder sb, SqlConversionProcessContext ctx)
      Called right after appending SqlFormatConstants.SELECT to the main selection part
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
    • handleAfterWithSelect

      default void handleAfterWithSelect(StringBuilder sb, SqlConversionProcessContext ctx, String... tables)
      Called right after appending SqlFormatConstants.SELECT to selection part of a WITH-element
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
      tables - the tables involved in the select
    • handleAfterScript

      default void handleAfterScript(StringBuilder sb, SqlConversionProcessContext ctx)
      Called after the SQL-script is complete (after finishing the main WHERE-clause)
      Parameters:
      sb - SQL-script string builder
      ctx - process context providing access to the state and utilities of the converter
    • init

      default void init()
      This method is called to initialize/reset the listener to avoid mixing state related to different conversion runs.
    • none

      static SqlAugmentationListener none()
      Returns a dummy instance
      Returns:
      listener instance that does not augment anything