Class AbstractSqlGenerator<T extends SqlStatement>

java.lang.Object
liquibase.sqlgenerator.core.AbstractSqlGenerator<T>
Type Parameters:
T - an implementation of the SqlStatement specifying which logical SQL statement an instance of this template class is able to generate SQL for.
All Implemented Interfaces:
PrioritizedService, SqlGenerator<T>
Direct Known Subclasses:
AddAutoIncrementGenerator, AddColumnGenerator, AddDefaultValueGenerator, AddForeignKeyConstraintGenerator, AddPrimaryKeyGenerator, AddUniqueConstraintGenerator, AlterSequenceGenerator, BatchDmlExecutablePreparedStatementGenerator, ClearDatabaseChangeLogTableGenerator, CommentGenerator, CopyRowsGenerator, CreateDatabaseChangeLogLockTableGenerator, CreateDatabaseChangeLogTableGenerator, CreateDatabaseChangeLogTableGeneratorSybase, CreateIndexGenerator, CreateProcedureGenerator, CreateSequenceGenerator, CreateTableGenerator, CreateViewGenerator, CreateViewGeneratorInformix, DeleteGenerator, DropColumnGenerator, DropDefaultValueGenerator, DropForeignKeyConstraintGenerator, DropIndexGenerator, DropPrimaryKeyGenerator, DropProcedureGenerator, DropSequenceGenerator, DropTableGenerator, DropUniqueConstraintGenerator, DropViewGenerator, GetNextChangeSetSequenceValueGenerator, GetViewDefinitionGenerator, InitializeDatabaseChangeLogLockTableGenerator, InsertDataChangeGenerator, InsertGenerator, InsertOrUpdateGenerator, InsertSetGenerator, LockDatabaseChangeLogGenerator, MarkChangeSetRanGenerator, ModifyDataTypeGenerator, RawParameterizedSqlGenerator, RawSqlGenerator, ReindexGeneratorSQLite, RemoveChangeSetRanStatusGenerator, RenameColumnGenerator, RenameSequenceGenerator, RenameTableGenerator, RenameViewGenerator, ReorganizeTableGeneratorDB2, RuntimeGenerator, SelectFromDatabaseChangeLogGenerator, SelectFromDatabaseChangeLogLockGenerator, SetColumnRemarksGenerator, SetNullableGenerator, SetTableRemarksGenerator, SetViewRemarksGenerator, StoredProcedureGenerator, TableIsEmptyGenerator, TableRowCountGenerator, TagDatabaseGenerator, UnlockDatabaseChangeLogGenerator, UpdateChangeSetChecksumGenerator, UpdateDataChangeGenerator, UpdateGenerator

public abstract class AbstractSqlGenerator<T extends SqlStatement> extends Object implements SqlGenerator<T>
Generic template class for an SQL generator able to generate SQL for an object-form SqlStatement.
  • Constructor Details

    • AbstractSqlGenerator

      public AbstractSqlGenerator()
  • Method Details

    • getPriority

      public int getPriority()
      Description copied from interface: SqlGenerator
      Of all the SqlGenerators that "support" a given SqlStatement/Database, SqlGeneratorFactory will return the one with the highest priority.
      Specified by:
      getPriority in interface PrioritizedService
      Specified by:
      getPriority in interface SqlGenerator<T extends SqlStatement>
    • generateStatementsIsVolatile

      public boolean generateStatementsIsVolatile(Database database)
      Description copied from interface: SqlGenerator
      Does this change require access to the database metadata? If true, the change cannot be used in an updateSql-style command.
      Specified by:
      generateStatementsIsVolatile in interface SqlGenerator<T extends SqlStatement>
    • generateRollbackStatementsIsVolatile

      public boolean generateRollbackStatementsIsVolatile(Database database)
      Specified by:
      generateRollbackStatementsIsVolatile in interface SqlGenerator<T extends SqlStatement>
    • supports

      public boolean supports(T statement, Database database)
      Description copied from interface: SqlGenerator
      Does this generator support the given statement/database combination? Do not validate the statement with this method, only return if it can support it.
      Specified by:
      supports in interface SqlGenerator<T extends SqlStatement>
    • warn

      public Warnings warn(T statementType, Database database, SqlGeneratorChain<T> sqlGeneratorChain)
      Specified by:
      warn in interface SqlGenerator<T extends SqlStatement>
    • looksLikeFunctionCall

      public boolean looksLikeFunctionCall(String value, Database database)
      Tries to find out if a given value (part a database-specific SQL statement) is just a simple literal (e.g. 'Jones', 149.99 or false) or if it is a call to a function within the database (e.g. TO_DATE('28.12.2017', 'dd.mm.yyyy') in Oracle DB). This method is often used to determine if we need to quote literals which are Strings, e.g. if we determine "Dr. Jones" to be a literal, then we generate
      INSERT INTO customers(last_name) VALUES('Dr. Jones')
      but if the value is a function call, we may not quote it, e.g. for "TO_DATE('28.12.2017', 'dd.mm.yyyy')", we need to generate (note the absence of the apostrophes!):
      INSERT INTO bookings(booking_date) VALUES (TO_DATE('28.12.2017', 'dd.mm.yyyy'))
      Parameters:
      value - The string to test
      database - the database object to test against
      Returns:
      true if value looks like a function call, false if it looks like a literal.