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

public abstract class DBDDLGenerator<T extends DBMSHandler> extends Object
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • dbms

      protected final T extends DBMSHandler dbms
    • DATATYPE_INT_SMALL

      protected String DATATYPE_INT_SMALL
    • DATATYPE_INTEGER

      protected String DATATYPE_INTEGER
    • DATATYPE_INT_BIG

      protected String DATATYPE_INT_BIG
    • DATATYPE_CHAR

      protected String DATATYPE_CHAR
    • DATATYPE_VARCHAR

      protected String DATATYPE_VARCHAR
    • DATATYPE_DATE

      protected String DATATYPE_DATE
    • DATATYPE_TIME

      protected String DATATYPE_TIME
    • DATATYPE_DATETIME

      protected String DATATYPE_DATETIME
    • DATATYPE_TIMESTAMP

      protected String DATATYPE_TIMESTAMP
    • DATATYPE_BOOLEAN

      protected String DATATYPE_BOOLEAN
    • DATATYPE_DECIMAL

      protected String DATATYPE_DECIMAL
    • DATATYPE_FLOAT

      protected String DATATYPE_FLOAT
    • DATATYPE_CLOB

      protected String DATATYPE_CLOB
    • DATATYPE_BLOB

      protected String DATATYPE_BLOB
    • DATATYPE_UNIQUEID

      protected String DATATYPE_UNIQUEID
    • namePrimaryKeyConstraint

      protected boolean namePrimaryKeyConstraint
    • alterColumnPhrase

      protected String alterColumnPhrase
    • databaseObjectName

      protected String databaseObjectName
    • ddlColumnDefaults

      protected boolean ddlColumnDefaults
  • Constructor Details

    • DBDDLGenerator

      protected DBDDLGenerator(T dbmsHandler)
  • Method Details

    • isDDLColumnDefaults

      public boolean isDDLColumnDefaults()
      Returns:
      true if column default values are created with dll statements or false if not
    • setDDLColumnDefaults

      public void setDDLColumnDefaults(boolean ddlColumnDefaults)
      Set true if column default values should be included in DDL Statements
      Parameters:
      ddlColumnDefaults - true if dll statements should include column default values or false if not
    • addCreateTableStmt

      protected void addCreateTableStmt(DBTable table, DBSQLBuilder sql, DBSQLScript script)
    • addCreateIndexStmt

      protected void addCreateIndexStmt(DBIndex index, DBSQLBuilder sql, DBSQLScript script)
    • addCreateRelationStmt

      protected void addCreateRelationStmt(DBRelation rel, DBSQLBuilder sql, DBSQLScript script)
    • addCreateViewStmt

      protected void addCreateViewStmt(DBView v, DBSQLBuilder sql, DBSQLScript script)
    • addAlterTableStmt

      protected void addAlterTableStmt(DBColumn col, DBSQLBuilder sql, DBSQLScript script)
    • appendColumnDataType

      protected boolean appendColumnDataType(DataType type, double size, DBTableColumn c, DBSQLBuilder sql)
      appends the data type of a column
      Parameters:
      type - the type
      size - the size
      c - the table column
      sql - the builder that we will append to
      Returns:
      true if further column attributes may be added or false otherwise
    • appendColumnDesc

      protected void appendColumnDesc(DBTableColumn c, boolean alter, DBSQLBuilder sql)
      Appends a table column definition to a ddl statement
      Parameters:
      c - the column which description to append
      alter - true if altering an existing column or false otherwise
      sql - the sql builder object
    • appendIndexColumn

      protected void appendIndexColumn(DBIndex index, DBColumnExpr idxColumn, DBSQLBuilder sql)
      Appends an column expression to an index
      Parameters:
      index - the index for which to append the column
      idxColumn - the index column
      sql - the SQL builder
    • appendIndexType

      protected void appendIndexType(DBIndex index, DBSQLBuilder sql)
      Appends the index type when creating an index
      Parameters:
      index - the index
      sql - the sql builder object
    • getDDLScript

      public void getDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script)
      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

      protected void createDatabase(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.
      Parameters:
      db - the database to create
      script - the sql script to which to append the dll command(s)
    • dropDatabase

      protected void dropDatabase(DBDatabase db, DBSQLScript script)
      Appends the DDL-Script for dropping a database to the given script object
      Parameters:
      db - the database to drop
      script - the sql script to which to append the dll command(s)
    • createTable

      protected void createTable(DBTable t, DBSQLScript script)
      Appends the DDL-Script for creating the given table to an SQL-Script
      Parameters:
      t - the table to create
      script - the sql script to which to append the dll command(s)
    • createTableIndexes

      protected void createTableIndexes(DBTable t, DBIndex pk, DBSQLScript script)
      Appends the DDL-Script for creating all indexes of table (except the primary key) to an SQL-Script
      Parameters:
      t - the table to create
      pk - the primary key index to ignore
      script - the sql script to which to append the dll command(s)
    • createIndex

      protected void createIndex(DBTable t, DBIndex index, DBSQLScript script)
      Appends the DDL-Script for creating a single index to an SQL-Script
      Parameters:
      t - the table
      index - the index to create
      script - the sql script to which to append the dll command(s)
    • createRelation

      protected void createRelation(DBRelation r, DBSQLScript script)
      Appends the DDL-Script for creating the given foreign-key relation to an SQL-Script
      Parameters:
      r - the relation to create
      script - the sql script to which to append the dll command(s)
    • alterTable

      protected void alterTable(DBTableColumn col, DBDDLGenerator.DDLActionType type, DBSQLScript script)
      Appends the DDL-Script for altering a table to an SQL-Script
      Parameters:
      col - the column which to add, modify or drop
      type - the type of operation to perform (CREATE | MODIFY | DROP)
      script - the sql script to which to append the dll command(s)
    • createView

      protected void createView(DBView v, DBSQLScript script)
      Appends the DDL-Script for creating the given view to an SQL-Script
      Parameters:
      v - the view to create
      script - the sql script to which to append the dll command(s)
    • dropObject

      protected void dropObject(String schema, String name, String objType, DBSQLScript script)
      Appends the DDL-Script for dropping a database object to an SQL-Script
      Parameters:
      schema - the name of the schema
      name - the name of the object to delete
      objType - the type of object to delete (TABLE, COLUMN, VIEW, RELATION, etc)
      script - the sql script to which to append the dll command(s)
    • appendElementName

      protected void appendElementName(DBSQLBuilder sql, String name)