|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ddlutils.platform.SqlBuilder
public abstract class SqlBuilder
This class is a collection of Strategy methods for creating the DDL required to create and drop databases and tables. It is hoped that just a single implementation of this class, for each database should make creating DDL for each physical database fairly straightforward. An implementation of this class can always delegate down to some templating technology such as Velocity if it requires. Though often that can be quite complex when attempting to reuse code across many databases. Hopefully only a small amount code needs to be changed on a per database basis.
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
_log
The Log to which logging calls will be made. |
protected static java.lang.String |
SIZE_PLACEHOLDER
The placeholder for the size value in the native type spec. |
Constructor Summary | |
---|---|
SqlBuilder(Platform platform)
Creates a new sql builder. |
Method Summary | |
---|---|
protected void |
addEscapedCharSequence(java.lang.String charSequence,
java.lang.String escapedVersion)
Adds a char sequence that needs escaping, and its escaped version. |
void |
alterDatabase(Database currentModel,
Database desiredModel,
CreationParameters params)
Generates the DDL to modify an existing database so the schema matches the specified database schema by using drops, modifications and additions. |
protected void |
applyForSelectedChanges(java.util.Collection changes,
java.lang.Class[] changeTypes,
org.apache.commons.collections.Closure closure)
Calls the given closure for all changes that are of one of the given types, and then removes them from the changes collection. |
protected boolean |
areEqual(java.lang.String string1,
java.lang.String string2,
boolean caseMatters)
Compares the two strings. |
protected boolean |
columnsDiffer(Column currentColumn,
Column desiredColumn)
Compares the current column in the database with the desired one. |
void |
createExternalForeignKeys(Database database)
Creates the external foreignkey creation statements for all tables in the database. |
void |
createExternalForeignKeys(Database database,
Table table)
Creates external foreignkey creation statements if necessary. |
void |
createTable(Database database,
Table table)
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). |
void |
createTable(Database database,
Table table,
java.util.Map parameters)
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). |
void |
createTables(Database database)
Outputs the DDL required to drop and (re)create all tables in the database model. |
void |
createTables(Database database,
boolean dropTables)
Outputs the DDL required to drop (if requested) and (re)create all tables in the database model. |
void |
createTables(Database database,
CreationParameters params,
boolean dropTables)
Outputs the DDL required to drop (if requested) and (re)create all tables in the database model. |
protected void |
createTemporaryTable(Database database,
Table table,
java.util.Map parameters)
Outputs the DDL to create the given temporary table. |
protected java.lang.String |
createUniqueIdentifier()
Creates a reasonably unique identifier only consisting of hexadecimal characters and underscores. |
void |
dropExternalForeignKeys(Table table)
Creates external foreignkey drop statements. |
void |
dropTable(Database database,
Table table)
Outputs the DDL required to drop the given table. |
void |
dropTable(Table table)
Outputs the DDL to drop the table. |
void |
dropTables(Database database)
Outputs the DDL required to drop the database. |
protected void |
dropTemporaryTable(Database database,
Table table)
Outputs the DDL to drop the given temporary table. |
protected java.lang.String |
escapeStringValue(java.lang.String value)
Escapes the necessary characters in given string value. |
protected ForeignKey |
findCorrespondingForeignKey(Table table,
ForeignKey fk)
Searches in the given table for a corresponding foreign key. |
protected java.lang.String |
getBareNativeType(Column column)
Returns the bare database-native type for the given column without any size specifies. |
protected java.lang.String |
getColumnName(Column column)
Returns the column name. |
java.lang.String |
getConstraintName(java.lang.String prefix,
Table table,
java.lang.String secondPart,
java.lang.String suffix)
Returns the constraint name. |
DefaultValueHelper |
getDefaultValueHelper()
Returns the default value helper. |
java.lang.String |
getDeleteSql(Table table,
java.util.Map pkValues,
boolean genPlaceholders)
Creates the SQL for deleting an object from the specified table. |
protected java.lang.String |
getDelimitedIdentifier(java.lang.String identifier)
Returns the delimited version of the identifier (if configured). |
java.lang.String |
getForeignKeyName(Table table,
ForeignKey fk)
Returns the name to be used for the given foreign key. |
java.lang.String |
getIndent()
Returns the string used to indent the SQL. |
java.lang.String |
getIndexName(Index index)
Returns the index name. |
java.lang.String |
getInsertSql(Table table,
java.util.Map columnValues,
boolean genPlaceholders)
Creates the SQL for inserting an object into the specified table. |
int |
getMaxColumnNameLength()
Returns the maximum number of characters that a column name can have. |
int |
getMaxConstraintNameLength()
Returns the maximum number of characters that a constraint name can have. |
int |
getMaxForeignKeyNameLength()
Returns the maximum number of characters that a foreign key name can have. |
int |
getMaxTableNameLength()
Returns the maximum number of characters that a table name can have. |
protected java.lang.String |
getNativeDefaultValue(Column column)
Returns the native default value for the column. |
protected java.lang.String |
getNativeType(Column column)
Returns the database-native type for the given column. |
Platform |
getPlatform()
Returns the platform object. |
PlatformInfo |
getPlatformInfo()
Returns the platform info object. |
protected Table |
getRealTargetTableFor(Database targetModel,
Table sourceTable,
Table targetTable)
Creates the target table object that differs from the given target table only in the indices. |
java.lang.String |
getSelectLastIdentityValues(Table table)
Generates the SQL for querying the id that was created in the last insertion operation. |
protected java.lang.String |
getSqlType(Column column)
Returns the full SQL type specification (including size and precision/scale) for the given column. |
java.lang.String |
getTableName(Table table)
Returns the table name. |
protected Table |
getTemporaryTableFor(Database targetModel,
Table targetTable)
Creates a temporary table object that corresponds to the given table. |
java.lang.String |
getUpdateSql(Table table,
java.util.Map columnValues,
boolean genPlaceholders)
Creates the SQL for updating an object in the specified table. |
protected java.lang.String |
getValueAsString(Column column,
java.lang.Object value)
Generates the string representation of the given value. |
protected java.text.DateFormat |
getValueDateFormat()
Returns the format object for formatting dates in the specified locale. |
java.lang.String |
getValueLocale()
Returns the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements). |
protected java.text.NumberFormat |
getValueNumberFormat()
Returns the format object for formatting numbers in the specified locale. |
protected java.text.DateFormat |
getValueTimeFormat()
Returns the format object for formatting times in the specified locale. |
java.io.Writer |
getWriter()
Returns the writer that the DDL is printed to. |
protected boolean |
isValidDefaultValue(java.lang.String defaultSpec,
int typeCode)
Determines whether the given default spec is a non-empty spec that shall be used in a DEFAULT expression. |
protected void |
print(java.lang.String text)
Prints some text. |
protected void |
printComment(java.lang.String text)
Prints an SQL comment to the current stream. |
protected void |
printDefaultValue(java.lang.Object defaultValue,
int typeCode)
Prints the default value of the column. |
protected void |
printEndOfStatement()
Prints the end of statement text, which is typically a semi colon followed by a carriage return. |
protected void |
printIdentifier(java.lang.String identifier)
Prints the given identifier. |
protected void |
printIndent()
Prints the characters used to indent SQL. |
protected void |
println()
Prints a newline. |
protected void |
println(java.lang.String text)
Prints some text followed by a newline. |
protected void |
printlnIdentifier(java.lang.String identifier)
Prints the given identifier followed by a newline. |
protected void |
printStartOfEmbeddedStatement()
Prints the start of an embedded statement. |
protected void |
processChange(Database currentModel,
Database desiredModel,
AddPrimaryKeyChange change)
Processes the addition of a primary key to a table. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
AddForeignKeyChange change)
Processes the change representing the addition of a foreign key. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
AddIndexChange change)
Processes the change representing the addition of an index. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
AddTableChange change)
Processes the change representing the addition of a table. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
ModelChange change)
This is a fall-through callback which generates a warning because a specific change type wasn't handled. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
RemoveForeignKeyChange change)
Processes the change representing the removal of a foreign key. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
RemoveIndexChange change)
Processes the change representing the removal of an index. |
protected void |
processChange(Database currentModel,
Database desiredModel,
CreationParameters params,
RemoveTableChange change)
Processes the change representing the removal of a table. |
protected void |
processChanges(Database currentModel,
Database desiredModel,
java.util.List changes,
CreationParameters params)
Processes the changes. |
protected void |
processTableStructureChanges(Database currentModel,
Database desiredModel,
CreationParameters params,
java.util.Collection changes)
Processes the changes to the structure of tables. |
protected void |
processTableStructureChanges(Database currentModel,
Database desiredModel,
java.lang.String tableName,
java.util.Map parameters,
java.util.List changes)
Processes the changes to the structure of a single table. |
protected void |
processTableStructureChanges(Database currentModel,
Database desiredModel,
Table sourceTable,
Table targetTable,
java.util.Map parameters,
java.util.List changes)
Allows database-specific implementations to handle changes in a database specific manner. |
void |
setIndent(java.lang.String indent)
Sets the string used to indent the SQL. |
protected void |
setValueDateFormat(java.text.DateFormat format)
Sets the format object for formatting dates in the specified locale. |
void |
setValueLocale(java.lang.String localeStr)
Sets the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements). |
protected void |
setValueNumberFormat(java.text.NumberFormat format)
Returns a new date format object for formatting numbers in the specified locale. |
protected void |
setValueTimeFormat(java.text.DateFormat format)
Sets the date format object for formatting times in the specified locale. |
void |
setWriter(java.io.Writer writer)
Sets the writer for printing the DDL to. |
java.lang.String |
shortenName(java.lang.String name,
int desiredLength)
Generates a version of the name that has at most the specified length. |
protected boolean |
shouldGeneratePrimaryKeys(Column[] primaryKeyColumns)
Determines whether we should generate a primary key constraint for the given primary key columns. |
protected void |
writeCastExpression(Column sourceColumn,
Column targetColumn)
Writes a cast expression that converts the value of the source column to the data type of the target column. |
protected void |
writeColumn(Table table,
Column column)
Outputs the DDL for the specified column. |
protected void |
writeColumnAutoIncrementStmt(Table table,
Column column)
Prints that the column is an auto increment column. |
protected void |
writeColumnDefaultValue(Table table,
Column column)
Prints the default value of the column. |
protected void |
writeColumnDefaultValueStmt(Table table,
Column column)
Prints the default value stmt part for the column. |
protected void |
writeColumnNotNullableStmt()
Prints that a column is not nullable. |
protected void |
writeColumnNullableStmt()
Prints that a column is nullable. |
protected void |
writeColumns(Table table)
Writes the columns of the given table. |
protected void |
writeCopyDataStatement(Table sourceTable,
Table targetTable)
Writes a statement that copies the data from the source to the target table. |
protected void |
writeEmbeddedForeignKeysStmt(Database database,
Table table)
Writes the foreign key constraints inside a create table () clause. |
protected void |
writeEmbeddedIndexCreateStmt(Table table,
Index index)
Writes the given embedded index of the table. |
protected void |
writeEmbeddedIndicesStmt(Table table)
Writes the indexes embedded within the create table statement. |
protected void |
writeEmbeddedPrimaryKeysStmt(Table table)
Writes the primary key constraints of the table inside its definition. |
protected void |
writeExternalForeignKeyCreateStmt(Database database,
Table table,
ForeignKey key)
Writes a single foreign key constraint using a alter table statement. |
protected void |
writeExternalForeignKeyDropStmt(Table table,
ForeignKey foreignKey)
Generates the statement to drop a foreignkey constraint from the database using an alter table statement. |
protected void |
writeExternalIndexCreateStmt(Table table,
Index index)
Writes the given index of the table. |
void |
writeExternalIndexDropStmt(Table table,
Index index)
Generates the statement to drop a non-embedded index from the database. |
protected void |
writeExternalIndicesCreateStmt(Table table)
Writes the indexes of the given table. |
protected void |
writeExternalPrimaryKeysCreateStmt(Table table,
Column[] primaryKeyColumns)
Writes the primary key constraints of the table as alter table statements. |
protected void |
writeForeignReferences(ForeignKey key)
Writes a list of foreign references for the given foreign key. |
protected void |
writeLocalReferences(ForeignKey key)
Writes a list of local references for the given foreign key. |
protected void |
writePrimaryKeyStmt(Table table,
Column[] primaryKeyColumns)
Writes a primary key statement for the given columns. |
protected void |
writeTableAlterStmt(Table table)
Generates the first part of the ALTER TABLE statement including the table name. |
protected void |
writeTableComment(Table table)
Outputs a comment for the table. |
protected void |
writeTableCreationStmt(Database database,
Table table,
java.util.Map parameters)
Writes the table creation statement without the statement end. |
protected void |
writeTableCreationStmtEnding(Table table,
java.util.Map parameters)
Writes the end of the table creation statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String SIZE_PLACEHOLDER
protected final org.apache.commons.logging.Log _log
Constructor Detail |
---|
public SqlBuilder(Platform platform)
platform
- The plaftform this builder belongs toMethod Detail |
---|
public Platform getPlatform()
public PlatformInfo getPlatformInfo()
public java.io.Writer getWriter()
public void setWriter(java.io.Writer writer)
writer
- The writerpublic DefaultValueHelper getDefaultValueHelper()
public java.lang.String getIndent()
public void setIndent(java.lang.String indent)
indent
- The indentation stringpublic java.lang.String getValueLocale()
null
if default formatting is usedpublic void setValueLocale(java.lang.String localeStr)
localeStr
- The new locale or null
if default formatting
should be used; Format is "language[_country[_variant]]"protected java.text.DateFormat getValueDateFormat()
protected void setValueDateFormat(java.text.DateFormat format)
format
- The date format objectprotected java.text.DateFormat getValueTimeFormat()
protected void setValueTimeFormat(java.text.DateFormat format)
format
- The time format objectprotected java.text.NumberFormat getValueNumberFormat()
protected void setValueNumberFormat(java.text.NumberFormat format)
format
- The number format objectprotected void addEscapedCharSequence(java.lang.String charSequence, java.lang.String escapedVersion)
charSequence
- The char sequenceescapedVersion
- The escaped versionpublic int getMaxTableNameLength()
public int getMaxColumnNameLength()
public int getMaxConstraintNameLength()
public int getMaxForeignKeyNameLength()
public void createTables(Database database) throws java.io.IOException
database
- The database model
java.io.IOException
public void createTables(Database database, boolean dropTables) throws java.io.IOException
database
- The databasedropTables
- Whether to drop tables before creating them
java.io.IOException
public void createTables(Database database, CreationParameters params, boolean dropTables) throws java.io.IOException
database
- The databaseparams
- The parameters used in the creationdropTables
- Whether to drop tables before creating them
java.io.IOException
public void alterDatabase(Database currentModel, Database desiredModel, CreationParameters params) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be applied
java.io.IOException
protected void applyForSelectedChanges(java.util.Collection changes, java.lang.Class[] changeTypes, org.apache.commons.collections.Closure closure)
changes
- The changeschangeTypes
- The types to search forclosure
- The closure to invokeprotected void processChanges(Database currentModel, Database desiredModel, java.util.List changes, CreationParameters params) throws java.io.IOException
RemoveForeignKeyChange
and
RemoveIndexChange
come first
to allow for e.g. subsequent primary key changes or column removal.RemoveTableChange
comes after the removal of foreign keys and indices.RemovePrimaryKeyChange
AddPrimaryKeyChange
PrimaryKeyChange
RemoveColumnChange
AddColumnChange
ColumnAutoIncrementChange
ColumnDefaultValueChange
ColumnRequiredChange
ColumnDataTypeChange
ColumnSizeChange
AddTableChange
AddForeignKeyChange
and
AddIndexChange
come last
after table/column/primary key additions or changes.
currentModel
- The current database schemadesiredModel
- The desired database schemachanges
- The changesparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be applied
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, ModelChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, RemoveForeignKeyChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, RemoveIndexChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, RemoveTableChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, AddTableChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, AddForeignKeyChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, CreationParameters params, AddIndexChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchange
- The change object
java.io.IOException
protected void processTableStructureChanges(Database currentModel, Database desiredModel, CreationParameters params, java.util.Collection changes) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemaparams
- The parameters used in the creation of new tables. Note that for existing
tables, the parameters won't be appliedchanges
- The change objects
java.io.IOException
protected void processTableStructureChanges(Database currentModel, Database desiredModel, java.lang.String tableName, java.util.Map parameters, java.util.List changes) throws java.io.IOException
processTableStructureChanges(Database, Database, Table, Table, Map, List)
method instead.
currentModel
- The current database schemadesiredModel
- The desired database schematableName
- The name of the changed tableparameters
- The creation parameters for the desired tablechanges
- The change objects for this table
java.io.IOException
protected void processTableStructureChanges(Database currentModel, Database desiredModel, Table sourceTable, Table targetTable, java.util.Map parameters, java.util.List changes) throws java.io.IOException
AddPrimaryKeyChange
changes are
applied via an ALTER TABLE ADD CONSTRAINT
statement.
currentModel
- The current database schemadesiredModel
- The desired database schemasourceTable
- The original tabletargetTable
- The desired tableparameters
- The creation parameters for the tablechanges
- The change objects for the target table
java.io.IOException
protected Table getTemporaryTableFor(Database targetModel, Table targetTable) throws java.io.IOException
targetModel
- The target databasetargetTable
- The target table
java.io.IOException
protected void createTemporaryTable(Database database, Table table, java.util.Map parameters) throws java.io.IOException
createTable(Database, Table, Map)
.
database
- The database modeltable
- The tableparameters
- Additional platform-specific parameters for the table creation
java.io.IOException
protected void dropTemporaryTable(Database database, Table table) throws java.io.IOException
dropTable(Table)
.
database
- The database modeltable
- The table
java.io.IOException
protected Table getRealTargetTableFor(Database targetModel, Table sourceTable, Table targetTable) throws java.io.IOException
targetModel
- The target databasesourceTable
- The source tabletargetTable
- The target table
java.io.IOException
protected void writeCopyDataStatement(Table sourceTable, Table targetTable) throws java.io.IOException
writeCastExpression(Column, Column)
method.
sourceTable
- The source tabletargetTable
- The target table
java.io.IOException
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws java.io.IOException
sourceColumn
- The source columntargetColumn
- The target column
java.io.IOException
protected void processChange(Database currentModel, Database desiredModel, AddPrimaryKeyChange change) throws java.io.IOException
currentModel
- The current database schemadesiredModel
- The desired database schemachange
- The change object
java.io.IOException
protected ForeignKey findCorrespondingForeignKey(Table table, ForeignKey fk)
table
- The table to search infk
- The original foreign key
protected boolean areEqual(java.lang.String string1, java.lang.String string2, boolean caseMatters)
string1
- The first stringstring2
- The second stringcaseMatters
- Whether case matters in the comparison
true
if the string are equalpublic void createTable(Database database, Table table) throws java.io.IOException
database
- The database modeltable
- The table
java.io.IOException
public void createTable(Database database, Table table, java.util.Map parameters) throws java.io.IOException
database
- The database modeltable
- The tableparameters
- Additional platform-specific parameters for the table creation
java.io.IOException
public void createExternalForeignKeys(Database database) throws java.io.IOException
database
- The database
java.io.IOException
public void createExternalForeignKeys(Database database, Table table) throws java.io.IOException
database
- The database modeltable
- The table
java.io.IOException
public void dropTables(Database database) throws java.io.IOException
database
- The database
java.io.IOException
public void dropTable(Database database, Table table) throws java.io.IOException
database
- The databasetable
- The table
java.io.IOException
public void dropTable(Table table) throws java.io.IOException
dropTable(Database, Table)
if you want that.
table
- The table to drop
java.io.IOException
public void dropExternalForeignKeys(Table table) throws java.io.IOException
table
- The table
java.io.IOException
public java.lang.String getInsertSql(Table table, java.util.Map columnValues, boolean genPlaceholders)
table
- The tablecolumnValues
- The columns values indexed by the column namesgenPlaceholders
- Whether to generate value placeholders for a
prepared statement
public java.lang.String getUpdateSql(Table table, java.util.Map columnValues, boolean genPlaceholders)
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 case genPlaceholders
is false
genPlaceholders
- Whether to generate value placeholders for a
prepared statement (both for the pk values and the object values)
public java.lang.String getDeleteSql(Table table, java.util.Map pkValues, boolean genPlaceholders)
table
- The tablepkValues
- The primary key values indexed by the column names, can be emptygenPlaceholders
- Whether to generate value placeholders for a
prepared statement
protected java.lang.String getValueAsString(Column column, java.lang.Object value)
column
- The columnvalue
- The value
public java.lang.String getSelectLastIdentityValues(Table table)
null
.
table
- The table
null
if the database does not support thispublic java.lang.String shortenName(java.lang.String name, int desiredLength)
name
- The original namedesiredLength
- The desired maximum length
public java.lang.String getTableName(Table table)
table
- The table
protected void writeTableComment(Table table) throws java.io.IOException
table
- The table
java.io.IOException
protected void writeTableAlterStmt(Table table) throws java.io.IOException
table
- The table being altered
java.io.IOException
protected void writeTableCreationStmt(Database database, Table table, java.util.Map parameters) throws java.io.IOException
database
- The modeltable
- The tableparameters
- Additional platform-specific parameters for the table creation
java.io.IOException
protected void writeTableCreationStmtEnding(Table table, java.util.Map parameters) throws java.io.IOException
table
- The tableparameters
- Additional platform-specific parameters for the table creation
java.io.IOException
protected void writeColumns(Table table) throws java.io.IOException
table
- The table
java.io.IOException
protected java.lang.String getColumnName(Column column) throws java.io.IOException
column
- The column
java.io.IOException
protected void writeColumn(Table table, Column column) throws java.io.IOException
table
- The table containing the columncolumn
- The column
java.io.IOException
protected java.lang.String getSqlType(Column column)
column
- The column
protected java.lang.String getNativeType(Column column)
column
- The column
protected java.lang.String getBareNativeType(Column column)
column
- The column
protected java.lang.String getNativeDefaultValue(Column column)
column
- The column
protected java.lang.String escapeStringValue(java.lang.String value)
value
- The value
protected boolean isValidDefaultValue(java.lang.String defaultSpec, int typeCode)
defaultSpec
- The default value spectypeCode
- The JDBC type code
true
if the default value spec is validprotected void writeColumnDefaultValueStmt(Table table, Column column) throws java.io.IOException
table
- The tablecolumn
- The column
java.io.IOException
protected void writeColumnDefaultValue(Table table, Column column) throws java.io.IOException
table
- The tablecolumn
- The column
java.io.IOException
protected void printDefaultValue(java.lang.Object defaultValue, int typeCode) throws java.io.IOException
defaultValue
- The default valuetypeCode
- The type code to write the default value for
java.io.IOException
protected void writeColumnAutoIncrementStmt(Table table, Column column) throws java.io.IOException
table
- The tablecolumn
- The column
java.io.IOException
protected void writeColumnNullableStmt() throws java.io.IOException
java.io.IOException
protected void writeColumnNotNullableStmt() throws java.io.IOException
java.io.IOException
protected boolean columnsDiffer(Column currentColumn, Column desiredColumn)
currentColumn
- The current column as it is in the databasedesiredColumn
- The desired column
true
if the column specifications differpublic java.lang.String getForeignKeyName(Table table, ForeignKey fk)
table
- The table for whith the foreign key is definedfk
- The foreign key
public java.lang.String getConstraintName(java.lang.String prefix, Table table, java.lang.String secondPart, java.lang.String suffix)
prefix
- The constraint prefix, can be null
table
- The table that the constraint belongs tosecondPart
- The second name part, e.g. the name of the constraint columnsuffix
- The constraint suffix, e.g. a counter (can be null
)
protected void writeEmbeddedPrimaryKeysStmt(Table table) throws java.io.IOException
table
- The table
java.io.IOException
protected void writeExternalPrimaryKeysCreateStmt(Table table, Column[] primaryKeyColumns) throws java.io.IOException
table
- The tableprimaryKeyColumns
- The primary key columns
java.io.IOException
protected boolean shouldGeneratePrimaryKeys(Column[] primaryKeyColumns)
primaryKeyColumns
- The pk columns
true
if a pk statement should be generated for the columnsprotected void writePrimaryKeyStmt(Table table, Column[] primaryKeyColumns) throws java.io.IOException
table
- The tableprimaryKeyColumns
- The primary columns
java.io.IOException
public java.lang.String getIndexName(Index index)
index
- The index
protected void writeExternalIndicesCreateStmt(Table table) throws java.io.IOException
table
- The table
java.io.IOException
protected void writeEmbeddedIndicesStmt(Table table) throws java.io.IOException
table
- The table
java.io.IOException
protected void writeExternalIndexCreateStmt(Table table, Index index) throws java.io.IOException
table
- The tableindex
- The index
java.io.IOException
protected void writeEmbeddedIndexCreateStmt(Table table, Index index) throws java.io.IOException
table
- The tableindex
- The index
java.io.IOException
public void writeExternalIndexDropStmt(Table table, Index index) throws java.io.IOException
table
- The table the index is onindex
- The index to drop
java.io.IOException
protected void writeEmbeddedForeignKeysStmt(Database database, Table table) throws java.io.IOException
database
- The database modeltable
- The table
java.io.IOException
protected void writeExternalForeignKeyCreateStmt(Database database, Table table, ForeignKey key) throws java.io.IOException
database
- The database modeltable
- The tablekey
- The foreign key
java.io.IOException
protected void writeLocalReferences(ForeignKey key) throws java.io.IOException
key
- The foreign key
java.io.IOException
protected void writeForeignReferences(ForeignKey key) throws java.io.IOException
key
- The foreign key
java.io.IOException
protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey) throws java.io.IOException
table
- The tableforeignKey
- The foreign key
java.io.IOException
protected void printComment(java.lang.String text) throws java.io.IOException
text
- The comment text
java.io.IOException
protected void printStartOfEmbeddedStatement() throws java.io.IOException
java.io.IOException
protected void printEndOfStatement() throws java.io.IOException
java.io.IOException
protected void println() throws java.io.IOException
java.io.IOException
protected void print(java.lang.String text) throws java.io.IOException
text
- The text to print
java.io.IOException
protected java.lang.String getDelimitedIdentifier(java.lang.String identifier)
identifier
- The identifier
protected void printIdentifier(java.lang.String identifier) throws java.io.IOException
identifier
- The identifier
java.io.IOException
protected void printlnIdentifier(java.lang.String identifier) throws java.io.IOException
identifier
- The identifier
java.io.IOException
protected void println(java.lang.String text) throws java.io.IOException
text
- The text to print
java.io.IOException
protected void printIndent() throws java.io.IOException
java.io.IOException
protected java.lang.String createUniqueIdentifier()
d578271282b42fce__2955b56e_107df3fbc96__8000
and is 48 characters long.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |