Class AbstractSqlGenerator

java.lang.Object
org.litebridge.db.spi.impl.sql.AbstractSqlGenerator
Direct Known Subclasses:
DeleteSqlGenerator, InsertSqlGenerator, MergeSqlGenerator, SelectSqlGenerator, UpdateSqlGenerator

public abstract class AbstractSqlGenerator extends Object
Abstract base class for SQL generators.
  • Field Details

  • Constructor Details

  • Method Details

    • createCondition

      protected String createCondition(Condition condition, ClauseType clauseType, Operation operation, ConnectionProvider connectionProvider)
      Generate a SQL condition string based on the given Condition. This method constructs the SQL fragment by combining the column, operator, and value (if applicable) for the provided condition.
      Parameters:
      condition - the Condition object specifying the column, operator, and value for the SQL condition
      clauseType - the current SQL clause type (e.g., WHERE, HAVING)`
      operation - the current database operation
      connectionProvider - the connection provider
      Returns:
      a PreparedSql representing the constructed SQL condition fragment
    • mapOperator

      protected String mapOperator(Operator operator)
      Map an Operator enum to its corresponding string representation used in logical or database operations.
      Parameters:
      operator - the Operator enum to be mapped
      Returns:
      the string representation of the provided Operator
    • createMathOperation

      protected String createMathOperation(String column, MathOperator mathOperator)
      Creates a SQL representation of a math operation.
      Parameters:
      column - the column
      mathOperator - the math operation
      Returns:
      the SQL representation of the math operation
    • appendTable

      protected StringBuilder appendTable(StringBuilder sql, Table table)
      Appends a table name to the SQL builder, quoting identifiers.
      Parameters:
      sql - The SQL builder.
      table - The table to append.
    • appendValues

      protected void appendValues(StringBuilder sql, Values values, Operation operation)
    • ensureColumnMetaData

      protected ColumnMetaData ensureColumnMetaData(Column column, ConnectionProvider connectionProvider)
      Ensures that column metadata is available for the specified column.
      Parameters:
      column - The column.
      connectionProvider - The connection provider.
      Returns:
      The column metadata.
    • appendConditionsAndSubgroups

      protected void appendConditionsAndSubgroups(StringBuilder sql, ConditionGroup conditionGroup, ClauseType clauseType, Operation operation, ConnectionProvider connectionProvider)
      Appends conditions and subgroups to the SQL builder.
      Parameters:
      sql - The SQL builder.
      conditionGroup - The condition group.
      clauseType - the current SQL clause type (e.g., WHERE, HAVING)`
      operation - The current database operation.
      connectionProvider - The connection provider.
    • getColumnValueFragment

      protected String getColumnValueFragment(UpdateColumn updateColumn, ClauseType clauseType, Operation operation)