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 Summary
Modifier and TypeMethodDescriptiondefault voidCalled right after appendingSqlFormatConstants.SELECTto the main selection partdefault voidhandleAfterOnConditions(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo) Called after finishing the ON-part of a joindefault voidCalled after the SQL-script is complete (after finishing the main WHERE-clause)default voidhandleAfterWithSelect(StringBuilder sb, SqlConversionProcessContext ctx, String... tables) Called right after appendingSqlFormatConstants.SELECTto selection part of a WITH-elementdefault voidhandleAppendJoinType(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo, String suggestedJoinType) The default implementation just appends the suggested join type e.g.default voidhandleBeforeMainStatement(StringBuilder sb, SqlConversionProcessContext ctx, boolean withClausePresent) Called before the main SELECT linedefault voidhandleBeforeOnClause(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo) Called right before printing the text "ON"default voidhandleBeforeOnConditions(StringBuilder sb, SqlConversionProcessContext ctx, String tableOrAliasFrom, String tableOrAliasTo) Called before printing an ON-condition, means right after the text "ON"default voidCalled before starting the SQL-scriptdefault voidinit()This method is called to initialize/reset the listener to avoid mixing state related to different conversion runs.static SqlAugmentationListenernone()Returns a dummy instance
-
Method Details
-
handleBeforeScript
Called before starting the SQL-script- Parameters:
sb- SQL-script string builderctx- 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 builderctx- process context providing access to the state and utilities of the converterwithClausePresent- 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 builderctx- process context providing access to the state and utilities of the convertertableOrAliasFrom- name of the table or alias we are coming fromtableOrAliasTo- name of the table or alias we are joiningsuggestedJoinType- 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 builderctx- process context providing access to the state and utilities of the convertertableOrAliasFrom- source table or aliastableOrAliasTo- 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 builderctx- process context providing access to the state and utilities of the convertertableOrAliasFrom- source table or aliastableOrAliasTo- 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 builderctx- process context providing access to the state and utilities of the convertertableOrAliasFrom- source table or aliastableOrAliasTo- table or alias to be joined
-
handleAfterMainSelect
Called right after appendingSqlFormatConstants.SELECTto the main selection part- Parameters:
sb- SQL-script string builderctx- 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 appendingSqlFormatConstants.SELECTto selection part of a WITH-element- Parameters:
sb- SQL-script string builderctx- process context providing access to the state and utilities of the convertertables- the tables involved in the select
-
handleAfterScript
Called after the SQL-script is complete (after finishing the main WHERE-clause)- Parameters:
sb- SQL-script string builderctx- 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
Returns a dummy instance- Returns:
- listener instance that does not augment anything
-