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 voidprotected voidcreateTable(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 StringCreates a reasonably unique identifier only consisting of hexadecimal characters and underscores.protected voiddropColumnChangeDefaults(Table sourceTable, Column sourceColumn, StringBuilder ddl) protected voiddropDefaultConstraint(Table table, String columnName, StringBuilder ddl) voiddropExternalForeignKeys(Table table, StringBuilder ddl) Creates external foreign key drop statements.protected voiddropTable(Table table, StringBuilder ddl, boolean temporary, boolean recreate) Outputs the DDL to drop the table.protected voidfilterColumnSqlType(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 StringgetNativeDefaultValue(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 StringgetValueAsString(Column column, Object value) Generates the string representation of the given value.protected DateFormatReturns the format object for formatting dates in the specified locale.protected DateFormatReturns the format object for formatting times in the specified locale.mapDefaultValue(Object defaultValue, Column column) protected voidprintAlwaysSingleQuotedIdentifier(String identifier, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, AddColumnChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, RemoveColumnChange change, StringBuilder ddl) protected voidprocessChange(Database currentModel, Database desiredModel, RemovePrimaryKeyChange change, StringBuilder ddl) protected voidprocessChanges(Database currentModel, Database desiredModel, List<IModelChange> changes, StringBuilder ddl) Processes the changes.protected voidprocessColumnChange(Table sourceTable, Table targetTable, Column sourceColumn, Column targetColumn, boolean typeChange, StringBuilder ddl) protected voidprocessTableStructureChanges(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 booleanshouldUseQuotes(String defaultValue, Column column) protected voidprotected voidprotected voidwriteColumnAutoIncrementStmt(Table table, Column column, StringBuilder ddl) Prints that the column is an auto increment column.protected voidwriteColumnDefaultValue(Table table, Column column, StringBuilder ddl) Prints the default value of the column.voidwriteCopyDataStatement(Table sourceTable, Table targetTable, StringBuilder ddl) Writes a statement that copies the data from the source to the target table.protected voidwriteExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey, StringBuilder ddl) Generates the statement to drop a foreignkey constraint from the database using an alter table statement.protected voidwriteGeneratedColumn(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, 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, processChanges, processTableStructureChanges, processTableStructureChanges, renameTable, restoreTableFromBackup, setCaseSensitive, setDelimitedIdentifierModeOn, setIndent, setScriptModeOn, setSqlCommentsOn, setValueDateFormat, setValueLocale, setValueNumberFormat, setValueTimeFormat, shortenName, shouldGeneratePrimaryKeys, writeAlterColumnDataTypeToBigInt, writeCascadeAttributesForForeignKey, writeCastExpression, writeColumn, 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, writeTableCreationStmt, writeTableCreationStmtEnding
-
Constructor Details
-
MsSql2000DdlBuilder
public MsSql2000DdlBuilder()
-
-
Method Details
-
addLobMapping
protected void addLobMapping() -
mapDefaultValue
- Specified by:
mapDefaultValuein interfaceIDdlBuilder- Overrides:
mapDefaultValuein classAbstractDdlBuilder
-
createTable
Description copied from class:AbstractDdlBuilderOutputs 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:
createTablein classAbstractDdlBuilderrecreate- TODO
-
dropTable
Description copied from class:AbstractDdlBuilderOutputs 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:
dropTablein classAbstractDdlBuilderrecreate- TODO
-
dropExternalForeignKeys
Description copied from class:AbstractDdlBuilderCreates external foreign key drop statements.- Overrides:
dropExternalForeignKeysin classAbstractDdlBuilder- Parameters:
table- The table
-
getValueDateFormat
Description copied from class:AbstractDdlBuilderReturns the format object for formatting dates in the specified locale.- Overrides:
getValueDateFormatin classAbstractDdlBuilder- Returns:
- The date format object or null if no locale is set
-
getValueTimeFormat
Description copied from class:AbstractDdlBuilderReturns the format object for formatting times in the specified locale.- Overrides:
getValueTimeFormatin classAbstractDdlBuilder- Returns:
- The time format object or null if no locale is set
-
getValueAsString
Description copied from class:AbstractDdlBuilderGenerates the string representation of the given value.- Overrides:
getValueAsStringin classAbstractDdlBuilder- Parameters:
column- The columnvalue- The value- Returns:
- The string representation
-
getNativeDefaultValue
Description copied from class:AbstractDdlBuilderReturns the native default value for the column.- Overrides:
getNativeDefaultValuein classAbstractDdlBuilder- Parameters:
column- The column- Returns:
- The native default value
-
writeColumnAutoIncrementStmt
Description copied from class:AbstractDdlBuilderPrints that the column is an auto increment column.- Overrides:
writeColumnAutoIncrementStmtin classAbstractDdlBuilder
-
writeExternalForeignKeyDropStmt
protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey, StringBuilder ddl) Description copied from class:AbstractDdlBuilderGenerates the statement to drop a foreignkey constraint from the database using an alter table statement.- Overrides:
writeExternalForeignKeyDropStmtin classAbstractDdlBuilder- Parameters:
table- The tableforeignKey- The foreign key
-
getSelectLastIdentityValues
Description copied from class:AbstractDdlBuilderGenerates 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:
getSelectLastIdentityValuesin classAbstractDdlBuilder- Parameters:
table- The table- Returns:
- The sql, or
nullif the database does not support this
-
getDeleteSql
Description copied from class:AbstractDdlBuilderCreates 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:
getDeleteSqlin 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:AbstractDdlBuilderCreates 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:
getInsertSqlin 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:AbstractDdlBuilderCreates 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:
getUpdateSqlin 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 casegenPlaceholdersisfalsegenPlaceholders- 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:AbstractDdlBuilderWrites 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:
writeCopyDataStatementin 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:AbstractDdlBuilderProcesses the changes. The default argument performs several passes:RemoveForeignKeyChangeandRemoveIndexChangecome first to allow for e.g. subsequent primary key changes or column removal.RemoveTableChangecomes 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.AddForeignKeyChangeandAddIndexChangecome last after table/column/primary key additions or changes.
- Overrides:
processChangesin classAbstractDdlBuilder
-
processTableStructureChanges
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, List<TableChange> changes, StringBuilder ddl) Description copied from class:AbstractDdlBuilderAllows 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, allAddPrimaryKeyChangechanges are applied via anALTER TABLE ADD CONSTRAINTstatement.- Overrides:
processTableStructureChangesin 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__8000and is 48 characters long.- Returns:
- The identifier
-
filterColumnSqlType
- Overrides:
filterColumnSqlTypein classAbstractDdlBuilder
-
writeColumnDefaultValue
Description copied from class:AbstractDdlBuilderPrints the default value of the column.- Overrides:
writeColumnDefaultValuein classAbstractDdlBuilder
-
shouldUseQuotes
- Overrides:
shouldUseQuotesin classAbstractDdlBuilder
-
writeGeneratedColumn
- Overrides:
writeGeneratedColumnin classAbstractDdlBuilder
-
writeCascadeAttributesForForeignKeyUpdate
- Overrides:
writeCascadeAttributesForForeignKeyUpdatein classAbstractDdlBuilder
-
writeCascadeAttributesForForeignKeyDelete
- Overrides:
writeCascadeAttributesForForeignKeyDeletein classAbstractDdlBuilder
-