Package org.apache.empire.db
Class DBDDLGenerator<T extends DBMSHandler>
java.lang.Object
org.apache.empire.db.DBDDLGenerator<T>
- Direct Known Subclasses:
DerbyDDLGenerator,H2DDLGenerator,HSqlDDLGenerator,MSSqlDDLGenerator,MySQLDDLGenerator,OracleDDLGenerator,PostgresDDLGenerator,SQLiteDDLGenerator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDDLActionType for DDLScript generation -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected final Tprotected booleanprotected static final org.slf4j.Loggerprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAlterTableStmt(DBColumn col, DBSQLBuilder sql, DBSQLScript script) protected voidaddCreateIndexStmt(DBIndex index, DBSQLBuilder sql, DBSQLScript script) protected voidaddCreateRelationStmt(DBRelation rel, DBSQLBuilder sql, DBSQLScript script) protected voidaddCreateTableStmt(DBTable table, DBSQLBuilder sql, DBSQLScript script) protected voidaddCreateViewStmt(DBView v, DBSQLBuilder sql, DBSQLScript script) protected voidalterTable(DBTableColumn col, DBDDLGenerator.DDLActionType type, DBSQLScript script) Appends the DDL-Script for altering a table to an SQL-Scriptprotected booleanappendColumnDataType(DataType type, double size, DBTableColumn c, DBSQLBuilder sql) appends the data type of a columnprotected voidappendColumnDesc(DBTableColumn c, boolean alter, DBSQLBuilder sql) Appends a table column definition to a ddl statementprotected voidappendElementName(DBSQLBuilder sql, String name) protected voidappendIndexColumn(DBIndex index, DBColumnExpr idxColumn, DBSQLBuilder sql) Appends an column expression to an indexprotected voidappendIndexType(DBIndex index, DBSQLBuilder sql) Appends the index type when creating an indexprotected voidcreateDatabase(DBDatabase db, DBSQLScript script) Appends the DDL-Script for creating the given database to an SQL-Script
This includes the generation of all tables, views and relations.protected voidcreateIndex(DBTable t, DBIndex index, DBSQLScript script) Appends the DDL-Script for creating a single index to an SQL-Scriptprotected voidcreateRelation(DBRelation r, DBSQLScript script) Appends the DDL-Script for creating the given foreign-key relation to an SQL-Scriptprotected voidcreateTable(DBTable t, DBSQLScript script) Appends the DDL-Script for creating the given table to an SQL-Scriptprotected voidcreateTableIndexes(DBTable t, DBIndex pk, DBSQLScript script) Appends the DDL-Script for creating all indexes of table (except the primary key) to an SQL-Scriptprotected voidcreateView(DBView v, DBSQLScript script) Appends the DDL-Script for creating the given view to an SQL-Scriptprotected voiddropDatabase(DBDatabase db, DBSQLScript script) Appends the DDL-Script for dropping a database to the given script objectprotected voiddropObject(String schema, String name, String objType, DBSQLScript script) Appends the DDL-Script for dropping a database object to an SQL-ScriptvoidgetDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script) Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.booleanvoidsetDDLColumnDefaults(boolean ddlColumnDefaults) Set true if column default values should be included in DDL Statements
-
Field Details
-
log
protected static final org.slf4j.Logger log -
dbms
-
DATATYPE_INT_SMALL
-
DATATYPE_INTEGER
-
DATATYPE_INT_BIG
-
DATATYPE_CHAR
-
DATATYPE_VARCHAR
-
DATATYPE_DATE
-
DATATYPE_TIME
-
DATATYPE_DATETIME
-
DATATYPE_TIMESTAMP
-
DATATYPE_BOOLEAN
-
DATATYPE_DECIMAL
-
DATATYPE_FLOAT
-
DATATYPE_CLOB
-
DATATYPE_BLOB
-
DATATYPE_UNIQUEID
-
namePrimaryKeyConstraint
protected boolean namePrimaryKeyConstraint -
alterColumnPhrase
-
databaseObjectName
-
ddlColumnDefaults
protected boolean ddlColumnDefaults
-
-
Constructor Details
-
DBDDLGenerator
-
-
Method Details
-
isDDLColumnDefaults
public boolean isDDLColumnDefaults()- Returns:
trueif column default values are created with dll statements orfalseif not
-
setDDLColumnDefaults
public void setDDLColumnDefaults(boolean ddlColumnDefaults) Set true if column default values should be included in DDL Statements- Parameters:
ddlColumnDefaults-trueif dll statements should include column default values orfalseif not
-
addCreateTableStmt
-
addCreateIndexStmt
-
addCreateRelationStmt
-
addCreateViewStmt
-
addAlterTableStmt
-
appendColumnDataType
protected boolean appendColumnDataType(DataType type, double size, DBTableColumn c, DBSQLBuilder sql) appends the data type of a column- Parameters:
type- the typesize- the sizec- the table columnsql- the builder that we will append to- Returns:
- true if further column attributes may be added or false otherwise
-
appendColumnDesc
Appends a table column definition to a ddl statement- Parameters:
c- the column which description to appendalter- true if altering an existing column or false otherwisesql- the sql builder object
-
appendIndexColumn
Appends an column expression to an index- Parameters:
index- the index for which to append the columnidxColumn- the index columnsql- the SQL builder
-
appendIndexType
Appends the index type when creating an index- Parameters:
index- the indexsql- the sql builder object
-
getDDLScript
Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.- Parameters:
type- operation to perform (CREATE, DROP, ALTER)dbo- the object for which to perform the operation (DBDatabase, DBTable, DBView, DBColumn, DBRelation)script- the script to which to add the DDL command(s)
-
createDatabase
Appends the DDL-Script for creating the given database to an SQL-Script
This includes the generation of all tables, views and relations.- Parameters:
db- the database to createscript- the sql script to which to append the dll command(s)
-
dropDatabase
Appends the DDL-Script for dropping a database to the given script object- Parameters:
db- the database to dropscript- the sql script to which to append the dll command(s)
-
createTable
Appends the DDL-Script for creating the given table to an SQL-Script- Parameters:
t- the table to createscript- the sql script to which to append the dll command(s)
-
createTableIndexes
Appends the DDL-Script for creating all indexes of table (except the primary key) to an SQL-Script- Parameters:
t- the table to createpk- the primary key index to ignorescript- the sql script to which to append the dll command(s)
-
createIndex
Appends the DDL-Script for creating a single index to an SQL-Script- Parameters:
t- the tableindex- the index to createscript- the sql script to which to append the dll command(s)
-
createRelation
Appends the DDL-Script for creating the given foreign-key relation to an SQL-Script- Parameters:
r- the relation to createscript- the sql script to which to append the dll command(s)
-
alterTable
Appends the DDL-Script for altering a table to an SQL-Script- Parameters:
col- the column which to add, modify or droptype- the type of operation to perform (CREATE | MODIFY | DROP)script- the sql script to which to append the dll command(s)
-
createView
Appends the DDL-Script for creating the given view to an SQL-Script- Parameters:
v- the view to createscript- the sql script to which to append the dll command(s)
-
dropObject
Appends the DDL-Script for dropping a database object to an SQL-Script- Parameters:
schema- the name of the schemaname- the name of the object to deleteobjType- the type of object to delete (TABLE, COLUMN, VIEW, RELATION, etc)script- the sql script to which to append the dll command(s)
-
appendElementName
-