Package liquibase.sqlgenerator
Interface SqlGenerator<T extends SqlStatement>
- Type Parameters:
T
- Used to specify which type of SqlStatement this generator supports. If it supports multiple SqlStatement types, pass SqlStatement. The SqlGeneratorFactory will use this parameter to augment the response from the supports() method
- All Superinterfaces:
PrioritizedService
- All Known Implementing Classes:
AbstractSqlGenerator
,AddAutoIncrementGenerator
,AddAutoIncrementGeneratorDB2
,AddAutoIncrementGeneratorHsqlH2
,AddAutoIncrementGeneratorInformix
,AddAutoIncrementGeneratorMySQL
,AddAutoIncrementGeneratorSQLite
,AddColumnGenerator
,AddColumnGeneratorDefaultClauseBeforeNotNull
,AddColumnGeneratorSQLite
,AddDefaultValueGenerator
,AddDefaultValueGeneratorDerby
,AddDefaultValueGeneratorInformix
,AddDefaultValueGeneratorMSSQL
,AddDefaultValueGeneratorMySQL
,AddDefaultValueGeneratorOracle
,AddDefaultValueGeneratorPostgres
,AddDefaultValueGeneratorSQLite
,AddDefaultValueGeneratorSybase
,AddDefaultValueGeneratorSybaseASA
,AddForeignKeyConstraintGenerator
,AddPrimaryKeyGenerator
,AddPrimaryKeyGeneratorInformix
,AddUniqueConstraintGenerator
,AddUniqueConstraintGeneratorInformix
,AddUniqueConstraintGeneratorTDS
,AlterSequenceGenerator
,BatchDmlExecutablePreparedStatementGenerator
,ClearDatabaseChangeLogTableGenerator
,CommentGenerator
,CopyRowsGenerator
,CreateDatabaseChangeLogLockTableGenerator
,CreateDatabaseChangeLogTableGenerator
,CreateDatabaseChangeLogTableGeneratorSybase
,CreateIndexGenerator
,CreateIndexGeneratorFirebird
,CreateIndexGeneratorPostgres
,CreateProcedureGenerator
,CreateSequenceGenerator
,CreateSequenceGeneratorSnowflake
,CreateTableGenerator
,CreateTableGeneratorInformix
,CreateViewGenerator
,CreateViewGeneratorInformix
,DeleteGenerator
,DropColumnGenerator
,DropDefaultValueGenerator
,DropDefaultValueGeneratorSnowflake
,DropForeignKeyConstraintGenerator
,DropIndexGenerator
,DropPrimaryKeyGenerator
,DropProcedureGenerator
,DropProcedureGeneratorSnowflake
,DropSequenceGenerator
,DropTableGenerator
,DropUniqueConstraintGenerator
,DropViewGenerator
,GetNextChangeSetSequenceValueGenerator
,GetViewDefinitionGenerator
,GetViewDefinitionGeneratorDB2
,GetViewDefinitionGeneratorDerby
,GetViewDefinitionGeneratorFirebird
,GetViewDefinitionGeneratorHsql
,GetViewDefinitionGeneratorInformix
,GetViewDefinitionGeneratorMSSQL
,GetViewDefinitionGeneratorOracle
,GetViewDefinitionGeneratorPostgres
,GetViewDefinitionGeneratorSnowflake
,GetViewDefinitionGeneratorSybase
,GetViewDefinitionGeneratorSybaseASA
,InitializeDatabaseChangeLogLockTableGenerator
,InsertDataChangeGenerator
,InsertGenerator
,InsertOrUpdateGenerator
,InsertOrUpdateGeneratorDB2
,InsertOrUpdateGeneratorH2
,InsertOrUpdateGeneratorHsql
,InsertOrUpdateGeneratorInformix
,InsertOrUpdateGeneratorMSSQL
,InsertOrUpdateGeneratorMySQL
,InsertOrUpdateGeneratorOracle
,InsertOrUpdateGeneratorPostgres
,InsertOrUpdateGeneratorSnowflake
,InsertOrUpdateGeneratorSQLite
,InsertOrUpdateGeneratorSybaseASA
,InsertSetGenerator
,LockDatabaseChangeLogGenerator
,MarkChangeSetRanGenerator
,ModifyDataTypeGenerator
,RawParameterizedSqlGenerator
,RawSqlGenerator
,ReindexGeneratorSQLite
,RemoveChangeSetRanStatusGenerator
,RenameColumnGenerator
,RenameSequenceGenerator
,RenameTableGenerator
,RenameTableGeneratorSnowflake
,RenameViewGenerator
,RenameViewGeneratorSnowflake
,ReorganizeTableGeneratorDB2
,RuntimeGenerator
,SelectFromDatabaseChangeLogGenerator
,SelectFromDatabaseChangeLogLockGenerator
,SetColumnRemarksGenerator
,SetColumnRemarksGeneratorSnowflake
,SetNullableGenerator
,SetTableRemarksGenerator
,SetTableRemarksGeneratorSnowflake
,SetViewRemarksGenerator
,StoredProcedureGenerator
,TableIsEmptyGenerator
,TableRowCountGenerator
,TagDatabaseGenerator
,UnlockDatabaseChangeLogGenerator
,UpdateChangeSetChecksumGenerator
,UpdateDataChangeGenerator
,UpdateGenerator
SqlGenerator implementations take a database-independent SqlStatement interface and create a
database-specific Sql object.
SqlGenerators are registered with the SqlGeneratorFactory, which is used to determine the correct generator to
use for a given statement/database combination.
The SqlGenerator implementations are responsible for determining whether the data contained in the SqlStatement method is valid using the validate method.
Naming Conventions:
Default SqlGenerators for a particular SqlStatement use the same name as the SqlStatement class, replacing
"Statement" with "Generator" (e.g.: CreateTableStatement -> CreateTableGenerator).
Database-specific or alternate SqlGenerators append a description of what makes them different appended
(e.g. CreateTableStatement -> CreateTableGeneratorOracle)
NOTE: There is only one instance of each SqlGenerator implementation created, and they must be thread safe.
Lifecycle:
- Instance of SqlGenerator subclass is created when registered with SqlGeneratorFactory
- For each SqlStatement to execute, SqlGeneratorFactory calls supports() to determine if the given SqlGenerator will work for the current SqlStatement/Database combination
- SqlGeneratorFactory calls getPriority to determine which of all the SqlGenerators that support a given SqlStatement/Database combination is the best to use.
- Liquibase calls validate() on the best SqlGenerator to determine if the data contained in the SqlStatement is correct and complete for the given Database
- If validate returns a no-error ValidationErrors object, Liquibase will call the generateSql() method and execute the resulting SQL against the database.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Sql[]
Represent an empty array ofSql
.static final int
static final int
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR
-
Method Summary
Modifier and TypeMethodDescriptionboolean
generateRollbackStatementsIsVolatile
(Database database) Sql[]
generateSql
(T statement, Database database, SqlGeneratorChain<T> sqlGeneratorChain) Generate the actual Sql for the given statement and database.boolean
generateStatementsIsVolatile
(Database database) Does this change require access to the database metadata?int
Of all the SqlGenerators that "support" a given SqlStatement/Database, SqlGeneratorFactory will return the one with the highest priority.boolean
Does this generator support the given statement/database combination?validate
(T statement, Database database, SqlGeneratorChain<T> sqlGeneratorChain) Validate the data contained in the SqlStatement.warn
(T statementType, Database database, SqlGeneratorChain<T> sqlGeneratorChain)
-
Field Details
-
PRIORITY_DEFAULT
static final int PRIORITY_DEFAULT- See Also:
-
PRIORITY_DATABASE
static final int PRIORITY_DATABASE- See Also:
-
EMPTY_SQL
Represent an empty array ofSql
.
-
-
Method Details
-
getPriority
int getPriority()Of all the SqlGenerators that "support" a given SqlStatement/Database, SqlGeneratorFactory will return the one with the highest priority.- Specified by:
getPriority
in interfacePrioritizedService
-
supports
Does this generator support the given statement/database combination? Do not validate the statement with this method, only return if it can support it. -
generateStatementsIsVolatile
Does this change require access to the database metadata? If true, the change cannot be used in an updateSql-style command. -
generateRollbackStatementsIsVolatile
-
validate
Validate the data contained in the SqlStatement. If there are no errors, return an empty ValidationErrors object, not a null value. Liquibase will inspect the ValidationErrors result before attempting to call generateSql. -
warn
-
generateSql
Generate the actual Sql for the given statement and database.
-