Package org.jumpmind.db.platform.mssql
Class MsSql2000DdlBuilder
java.lang.Object
org.jumpmind.db.platform.AbstractDdlBuilder
org.jumpmind.db.platform.mssql.MsSql2000DdlBuilder
- All Implemented Interfaces:
IDdlBuilder
- Direct Known Subclasses:
MsSql2005DdlBuilder
-
Field Summary
Fields inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
caseSensitive, databaseInfo, databaseName, delimitedIdentifierModeOn, log, scriptModeOn, SIZE_PLACEHOLDER, sqlCommentsOn
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
createTable
(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).protected String
Creates a reasonably unique identifier only consisting of hexadecimal characters and underscores.protected void
dropColumnChangeDefaults
(Table sourceTable, Column sourceColumn, StringBuilder ddl) protected void
dropDefaultConstraint
(Table table, String columnName, StringBuilder ddl) void
dropExternalForeignKeys
(Table table, StringBuilder ddl) Creates external foreign key drop statements.protected void
dropTable
(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to drop the table.protected void
filterColumnSqlType
(StringBuilder sqlType) getDeleteSql
(Table table, Map<String, Object> pkValues, boolean genPlaceholders) Creates the SQL for deleting an object from the specified table.getInsertSql
(Table table, Map<String, Object> columnValues, boolean genPlaceholders) Creates the SQL for inserting an object into the specified table.protected String
getNativeDefaultValue
(Column column) Returns the native default value for the column.getSelectLastIdentityValues
(Table table) Generates the SQL for querying the id that was created in the last insertion operation.getUpdateSql
(Table table, Map<String, Object> columnValues, boolean genPlaceholders) Creates the SQL for updating an object in the specified table.protected String
getValueAsString
(Column column, Object value) Generates the string representation of the given value.protected DateFormat
Returns the format object for formatting dates in the specified locale.protected DateFormat
Returns the format object for formatting times in the specified locale.mapDefaultValue
(Object defaultValue, Column column) protected void
printAlwaysSingleQuotedIdentifier
(String identifier, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) protected void
processChange
(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) protected void
processChanges
(Database currentModel, Database desiredModel, List<IModelChange> changes, StringBuilder ddl) Processes the changes.protected void
processColumnChange
(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, boolean typeChange, StringBuilder ddl) protected void
processTableStructureChanges
(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Allows database-specific implementations to handle changes in a database specific manner.protected boolean
shouldUseQuotes
(String defaultValue, Column column) protected void
protected void
protected void
writeColumnAutoIncrementStmt
(Table table, Column column, StringBuilder ddl) Prints that the column is an auto increment column.protected void
writeColumnDefaultValue
(Table table, Column column, StringBuilder ddl) Prints the default value of the column.void
writeCopyDataStatement
(Table sourceTable, Table targetTable, StringBuilder ddl) Writes a statement that copies the data from the source to the target table.protected void
writeExternalForeignKeyDropStmt
(Table table, ForeignKey foreignKey, StringBuilder ddl) Generates the statement to drop a foreignkey constraint from the database using an alter table statement.protected void
writeGeneratedColumn
(Table table, Column column, StringBuilder ddl) Methods inherited from class org.jumpmind.db.platform.AbstractDdlBuilder
addEscapedCharSequence, alterDatabase, alterDatabase, alterTable, areColumnSizesTheSame, areEqual, areMappedTypesTheSame, copy, createBackupTableFor, createExternalForeignKeys, createExternalForeignKeys, createTable, createTables, createTables, createTemporaryTable, dropTable, dropTables, dropTables, dropTemporaryTable, escapeStringValue, filterChanges, findCorrespondingForeignKey, findForeignKey, findTable, fixLastIdentityValues, getBackupTableFor, getBareNativeType, getColumnName, getColumnTypeDdl, getConstraintName, getCopyDataColumnMapping, getCopyDataColumnOrderedMapping, getDatabaseInfo, getDefaultValueHelper, getDefinitionForGeneratedColumn, getDelimitedIdentifier, getDetectedChanges, getForeignKeyName, getFullyQualifiedIndexNameShorten, getFullyQualifiedTableNameShorten, getGapLimitSize, getIndent, getIndexName, getNativeType, getRealTargetTableFor, getSize, getSqlType, getTableName, getTemporaryTableFor, getTemporaryTableFor, getTriggerDelimiterReplacementCharacters, getValueLocale, getValueNumberFormat, hasSize, initCteExpression, isAlterDatabase, isCaseSensitive, isDelimitedIdentifierModeOn, isFullTextIndex, isScriptModeOn, isSpecifyIdentityGapLimit, isSqlCommentsOn, isValidDefaultValue, mergeOrRemovePlatformTypes, printComment, printDefaultValue, printEndOfStatement, printIdentifier, printIndent, println, println, printlnIdentifier, printStartOfEmbeddedStatement, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChange, processChanges, processTableStructureChanges, processTableStructureChanges, renameTable, replaceDelimiterWithEscapeCharacters, restoreTableFromBackup, setCaseSensitive, setDelimitedIdentifierModeOn, setIndent, setScriptModeOn, setSqlCommentsOn, setTriggerDelimiterReplacementCharacters, setValueDateFormat, setValueLocale, setValueNumberFormat, setValueTimeFormat, shortenName, shouldGeneratePrimaryKeys, writeAlterColumnDataTypeToBigInt, writeCascadeAttributesForForeignKey, writeCastExpression, writeColumn, writeColumnAutoUpdateStmt, writeColumnDefaultValueStmt, writeColumnEmbeddedPrimaryKey, writeColumnNotNullableStmt, writeColumnNullableStmt, writeColumns, writeColumnType, writeColumnTypeDefaultRequired, writeColumnUniqueStmt, writeCopyDataStatement, writeEmbeddedForeignKeysStmt, writeEmbeddedIndexCreateStmt, writeEmbeddedIndicesStmt, writeEmbeddedPrimaryKeysStmt, writeExternalForeignKeyCreateStmt, writeExternalIndexCreate, writeExternalIndexCreateStmt, writeExternalIndexDropStmt, writeExternalIndicesCreateStmt, writeExternalPrimaryKeysCreateStmt, writeFixLastIdentityValues, writeForeignReferences, writeIdentityGapLimit, writeLocalReferences, writePrimaryKeyStmt, writeTableAlterStmt, writeTableComment, writeTableCreateOpeningStmt, writeTableCreationStmt, writeTableCreationStmtEnding
-
Constructor Details
-
MsSql2000DdlBuilder
public MsSql2000DdlBuilder()
-
-
Method Details
-
addLobMapping
protected void addLobMapping() -
mapDefaultValue
- Specified by:
mapDefaultValue
in interfaceIDdlBuilder
- Overrides:
mapDefaultValue
in classAbstractDdlBuilder
-
createTable
Description copied from class:AbstractDdlBuilder
Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).- Overrides:
createTable
in classAbstractDdlBuilder
recreate
- TODO
-
dropTable
Description copied from class:AbstractDdlBuilder
Outputs the DDL to drop the table. Note that this method does not drop foreign keys to this table. Use#dropTable(Database, Table)
if you want that.- Overrides:
dropTable
in classAbstractDdlBuilder
recreate
- TODO
-
dropExternalForeignKeys
Description copied from class:AbstractDdlBuilder
Creates external foreign key drop statements.- Overrides:
dropExternalForeignKeys
in classAbstractDdlBuilder
- Parameters:
table
- The table
-
getValueDateFormat
Description copied from class:AbstractDdlBuilder
Returns the format object for formatting dates in the specified locale.- Overrides:
getValueDateFormat
in classAbstractDdlBuilder
- Returns:
- The date format object or null if no locale is set
-
getValueTimeFormat
Description copied from class:AbstractDdlBuilder
Returns the format object for formatting times in the specified locale.- Overrides:
getValueTimeFormat
in classAbstractDdlBuilder
- Returns:
- The time format object or null if no locale is set
-
getValueAsString
Description copied from class:AbstractDdlBuilder
Generates the string representation of the given value.- Overrides:
getValueAsString
in classAbstractDdlBuilder
- Parameters:
column
- The columnvalue
- The value- Returns:
- The string representation
-
getNativeDefaultValue
Description copied from class:AbstractDdlBuilder
Returns the native default value for the column.- Overrides:
getNativeDefaultValue
in classAbstractDdlBuilder
- Parameters:
column
- The column- Returns:
- The native default value
-
writeColumnAutoIncrementStmt
Description copied from class:AbstractDdlBuilder
Prints that the column is an auto increment column.- Overrides:
writeColumnAutoIncrementStmt
in classAbstractDdlBuilder
-
writeExternalForeignKeyDropStmt
protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey, StringBuilder ddl) Description copied from class:AbstractDdlBuilder
Generates the statement to drop a foreignkey constraint from the database using an alter table statement.- Overrides:
writeExternalForeignKeyDropStmt
in classAbstractDdlBuilder
- Parameters:
table
- The tableforeignKey
- The foreign key
-
getSelectLastIdentityValues
Description copied from class:AbstractDdlBuilder
Generates the SQL for querying the id that was created in the last insertion operation. This is obviously only useful for pk fields that are auto-incrementing. A database that does not support this, will returnnull
.- Overrides:
getSelectLastIdentityValues
in classAbstractDdlBuilder
- Parameters:
table
- The table- Returns:
- The sql, or
null
if the database does not support this
-
getDeleteSql
Description copied from class:AbstractDdlBuilder
Creates the SQL for deleting an object from the specified table. If values are given then a concrete delete statement is created, otherwise an delete statement usable in a prepared statement is build.- Overrides:
getDeleteSql
in classAbstractDdlBuilder
- Parameters:
table
- The tablepkValues
- The primary key values indexed by the column names, can be emptygenPlaceholders
- Whether to generate value placeholders for a prepared statement- Returns:
- The delete sql
-
getInsertSql
Description copied from class:AbstractDdlBuilder
Creates the SQL for inserting an object into the specified table. If values are given then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.- Overrides:
getInsertSql
in classAbstractDdlBuilder
- Parameters:
table
- The tablecolumnValues
- The columns values indexed by the column namesgenPlaceholders
- Whether to generate value placeholders for a prepared statement- Returns:
- The insertion sql
-
getUpdateSql
Description copied from class:AbstractDdlBuilder
Creates the SQL for updating an object in the specified table. If values are given then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.- Overrides:
getUpdateSql
in classAbstractDdlBuilder
- Parameters:
table
- The tablecolumnValues
- Contains the values for the columns to update, and should also contain the primary key values to identify the object to update in casegenPlaceholders
isfalse
genPlaceholders
- Whether to generate value placeholders for a prepared statement (both for the pk values and the object values)- Returns:
- The update sql
-
printAlwaysSingleQuotedIdentifier
-
writeCopyDataStatement
Description copied from class:AbstractDdlBuilder
Writes a statement that copies the data from the source to the target table. Note that this copies only those columns that are in both tables. Database-specific implementations might redefine this method though they usually it suffices to redefine the#writeCastExpression(Column, Column)
method.- Overrides:
writeCopyDataStatement
in classAbstractDdlBuilder
- Parameters:
sourceTable
- The source tabletargetTable
- The target table
-
processChanges
protected void processChanges(Database currentModel, Database desiredModel, List<IModelChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilder
Processes the changes. The default argument performs several passes:RemoveForeignKeyChange
andRemoveIndexChange
come first to allow for e.g. subsequent primary key changes or column removal.RemoveTableChange
comes after the removal of foreign keys and indices.- These are all handled together:
RemovePrimaryKeyChange
AddPrimaryKeyChange
PrimaryKeyChange
RemoveColumnChange
AddColumnChange
ColumnAutoIncrementChange
ColumnDefaultValueChange
ColumnRequiredChange
ColumnDataTypeChange
ColumnSizeChange
The reason for this is that the default algorithm rebuilds the table for these changes and thus their order is irrelevant. AddTableChange
needs to come after the table removal (so that tables of the same name are removed) and before the addition of foreign keys etc.AddForeignKeyChange
andAddIndexChange
come last after table/column/primary key additions or changes.RemoveTriggerChange
come after the tables are completely built.AddTriggerChange
is done last.
- Overrides:
processChanges
in classAbstractDdlBuilder
-
processTableStructureChanges
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilder
Allows database-specific implementations to handle changes in a database specific manner. Any handled change should be applied to the given current model (which is a copy of the real original model) and be removed from the list of changes.
In the default implementation, allAddPrimaryKeyChange
changes are applied via anALTER TABLE ADD CONSTRAINT
statement.- Overrides:
processTableStructureChanges
in classAbstractDdlBuilder
- Parameters:
currentModel
- The current database schemadesiredModel
- The desired database schemasourceTable
- The original tabletargetTable
- The desired tablechanges
- The change objects for the target table
-
processChange
protected void processChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) -
processChange
protected void processChange(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) -
dropDefaultConstraint
-
processColumnChange
protected void processColumnChange(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, boolean typeChange, StringBuilder ddl) -
dropColumnChangeDefaults
-
createUniqueIdentifier
Creates a reasonably unique identifier only consisting of hexadecimal characters and underscores. It looks liked578271282b42fce__2955b56e_107df3fbc96__8000
and is 48 characters long.- Returns:
- The identifier
-
filterColumnSqlType
- Overrides:
filterColumnSqlType
in classAbstractDdlBuilder
-
writeColumnDefaultValue
Description copied from class:AbstractDdlBuilder
Prints the default value of the column.- Overrides:
writeColumnDefaultValue
in classAbstractDdlBuilder
-
shouldUseQuotes
- Overrides:
shouldUseQuotes
in classAbstractDdlBuilder
-
writeGeneratedColumn
- Overrides:
writeGeneratedColumn
in classAbstractDdlBuilder
-
writeCascadeAttributesForForeignKeyUpdate
- Overrides:
writeCascadeAttributesForForeignKeyUpdate
in classAbstractDdlBuilder
-
writeCascadeAttributesForForeignKeyDelete
- Overrides:
writeCascadeAttributesForForeignKeyDelete
in classAbstractDdlBuilder
-