Interface TableManager

  • All Known Subinterfaces:
    JChemTableManager

    public interface TableManager
    Manager for the tables in a database. DDL operations should be performed using this class. The key aspect of this class is the TableSetInfo inner class which represents a database table, or in some circumstances a collection of tables that operate as as single unit.
    Author:
    Tim Dudgeon
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      com.im.commons.db.ddl.DBColInfo addColumn​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, java.lang.String columnName, java.lang.String colClass, java.lang.String nativeType, java.lang.String colDefinition, java.lang.String colDefault, boolean isNotNull, com.im.commons.progress.DFFeedback feedback)
      Add a column to the main table
      com.im.commons.db.ddl.DBForeignKeyInfo addForeignKey​(java.lang.String fkName, java.lang.String parentSchema, java.lang.String parentTable, java.lang.String dependentSchema, java.lang.String dependentTable, java.lang.String[] parentCols, java.lang.String[] dependentCols, java.lang.String onDeleteRule, java.lang.String onUpdateRule)  
      com.im.commons.db.ddl.DBIndexInfo addIndex​(java.lang.String schemaPlusIndexName, java.lang.String indexType, java.lang.String schemaPlusTableName, java.util.List<java.lang.String> columns, java.util.List<java.lang.Boolean> order, com.im.commons.progress.DFFeedback feedback)
      Add an index to a table See DBIndexCapability for more information
      com.im.commons.db.ddl.DBSequenceInfo addSequence​(java.lang.String dbSchemaName, java.lang.String seqName, com.im.commons.progress.DFFeedback feedback)
      Add the specified sequence
      com.im.commons.db.ddl.DBConstraintInfo addUniqueConstraint​(java.lang.String dbSchemaName, java.lang.String table, java.lang.String constraintName, java.util.List<java.lang.String> columns, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.tablesets.TableSetInfo createGenericTable​(java.lang.String dbSchemaName, java.lang.String tableName, java.util.List<com.im.commons.db.ddl.DBDatabaseInfo.NativeType> columnDefs, java.util.List<java.lang.String> columnNames, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.tablesets.TableSetInfo createInlineView​(java.lang.String dbSchemaName, java.lang.String viewName, java.lang.String primaryKeyColumnName, java.lang.String sql, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.tablesets.TableSetInfo createStandardTable​(java.lang.String dbSchemaName, java.lang.String tableName, java.lang.String idColumnName, java.lang.String extraCols, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.tablesets.TableSetInfo createView​(java.lang.String dbSchemaName, java.lang.String viewName, java.lang.String viewDefSQL, com.im.commons.progress.DFFeedback feedback)  
      void dropColumn​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, java.lang.String columnName, com.im.commons.progress.DFFeedback feedback)  
      void dropForeignKeyConstraint​(com.im.commons.db.ddl.DBForeignKeyInfo foreingKeyInfo, com.im.commons.progress.DFFeedback feedback)  
      void dropIndex​(com.im.commons.db.ddl.DBIndexInfo index, com.im.commons.progress.DFFeedback feedback)
      Drop this index
      void dropSequence​(java.lang.String dbSchemaName, java.lang.String sequenceName, com.im.commons.progress.DFFeedback feedback)  
      void dropTables​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, com.im.commons.progress.DFFeedback feedback)
      Drop this table, and any others that it uses
      void dropTrigger​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, java.lang.String triggerName, com.im.commons.progress.DFFeedback feedback)  
      void dropUniqueConstraint​(java.lang.String dbSchemaName, java.lang.String table, com.im.commons.db.ddl.DBConstraintInfo constraint, com.im.commons.progress.DFFeedback feedback)  
      java.lang.String generateTableStatistics​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet)  
      com.im.commons.db.util.SchemaQualifiedName[] getConstraintNames()  
      com.im.commons.db.ddl.DBItemsCache getDBItemsCache()  
      com.im.commons.db.ddl.DBIndexInfo getIndexInfo​(java.lang.String dbSchemaName, java.lang.String indexName)
      Get the description for this index
      java.util.List<com.im.commons.db.ddl.DBIndexInfo> getIndexInfos​(java.lang.String dbSchemaName, java.lang.String tableName)
      See index descriptions for this table
      com.im.commons.db.ddl.DBTableInfo getTableInfo​(java.lang.String dbSchemaName, java.lang.String name)
      Get the table info for the specified table or view.
      com.im.commons.db.ddl.DBTableInfo getTableInfoFull​(java.lang.String dbSchemaName, java.lang.String name)  
      com.im.commons.db.ddl.DBTableInfo getTableInfoIgnoreCache​(java.lang.String dbSchemaName, java.lang.String name, com.im.commons.progress.DFFeedback feedback)  
      java.lang.String[] getTableNames​(java.lang.String dbSchemaName)
      Get the names of the tables that are accessible from this schema.
      com.im.commons.db.ddl.tablesets.TableSetInfo getTableSetInfo​(java.lang.String dbSchemaName, java.lang.String name, java.lang.String entityType)
      Get the table description for the table cluster.
      com.im.commons.db.ddl.tablesets.TableSetInfo getTableSetInfoFull​(java.lang.String dbSchemaName, java.lang.String name, java.lang.String entityType)  
      java.lang.String[] getViewNames​(java.lang.String dbSchemaName)
      Get the names of the views that are accessible from this schema.
      void initLazyLoading​(DDLService ddlService)  
      void initTableSetInfos​(SchemaInfo.PerformanceMode performanceMode, java.util.Collection<? extends com.im.commons.db.ddl.tablesets.TableSetInfo> tableSetInfos, java.util.Collection<? extends com.im.commons.db.ddl.DBTableInfo> virtualTableInfos, java.util.Collection<java.lang.String> tableNamesUsedByIJCSchema, com.im.commons.progress.DFFeedback feedback)  
      void rebuildIndex​(com.im.commons.db.ddl.DBIndexInfo index, com.im.commons.progress.DFFeedback feedback)
      Rebuild this index
      void setDBSchemas​(java.util.List<java.lang.String> dbSchemasNames, com.im.commons.progress.DFFeedback feedback)
      Should be called only once - at the moment when all schema names are available.
      boolean tableExists​(java.lang.String dbSchemaName, java.lang.String table)
      Find out if this is a real table, view etc.
      com.im.commons.db.ddl.DBColInfo updateColumnDefault​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, com.im.commons.db.ddl.DBColInfo colInfo, java.lang.String defaultValue, com.im.commons.progress.DFFeedback feedback)  
      void updateColumnDefault​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, java.lang.String column, java.lang.Class columnClass, java.lang.String nativeType, java.lang.String columnDefinition, java.lang.String defaultValue, boolean required, com.im.commons.progress.DFFeedback feedback)
      Deprecated.
      com.im.commons.db.ddl.DBColInfo updateColumnDefinition​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, com.im.commons.db.ddl.DBColInfo colInfo, java.lang.String columnDefinition, com.im.commons.progress.DFFeedback feedback)
      Currently can only update the column size, so the name of this method is misleading
      void updateColumnDefinition​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, java.lang.String columnName, java.lang.String columnDefinition, com.im.commons.progress.DFFeedback feedback)
      Deprecated. 
      com.im.commons.db.ddl.DBColInfo updateColumnName​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, com.im.commons.db.ddl.DBColInfo colInfo, java.lang.String columnName, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.DBColInfo updateColumnRequired​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, com.im.commons.db.ddl.DBColInfo colInfo, boolean required, com.im.commons.progress.DFFeedback feedback)  
      com.im.commons.db.ddl.DBColInfo updateColumnRequired​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, int tableIndex, java.lang.String column, java.lang.String nativeType, java.lang.String columnDefinition, java.lang.String defaultValue, boolean required, com.im.commons.progress.DFFeedback feedback)
      Deprecated.
      com.im.commons.db.ddl.tablesets.TableSetInfo updateTableName​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet, java.lang.String newName, com.im.commons.progress.DFFeedback feedback)  
    • Method Detail

      • initLazyLoading

        void initLazyLoading​(DDLService ddlService)
      • setDBSchemas

        void setDBSchemas​(java.util.List<java.lang.String> dbSchemasNames,
                          com.im.commons.progress.DFFeedback feedback)
        Should be called only once - at the moment when all schema names are available.
      • initTableSetInfos

        void initTableSetInfos​(SchemaInfo.PerformanceMode performanceMode,
                               java.util.Collection<? extends com.im.commons.db.ddl.tablesets.TableSetInfo> tableSetInfos,
                               java.util.Collection<? extends com.im.commons.db.ddl.DBTableInfo> virtualTableInfos,
                               java.util.Collection<java.lang.String> tableNamesUsedByIJCSchema,
                               com.im.commons.progress.DFFeedback feedback)
        Parameters:
        performanceMode - Schema performance mode.
        tableSetInfos - The list of TableSetInfos to use. If null the TableSetInfos will be extracted from the database metadata and will reflect the current list database tables and views.
        virtualTableInfos - The list of DBTableInfos for inline views that also need to be initialized. Can be null if there are no inline views.
        tableNamesUsedByIJCSchema - The list of schema-qualified names of tables that are used by entities in the IJC schema. It's ignored if tableSetInfos parameter is specified. It's used as a hint for loading DBTableInfos from the database metadata. Can be null.
        feedback - Feedback using call backs.
      • getDBItemsCache

        com.im.commons.db.ddl.DBItemsCache getDBItemsCache()
        Returns:
        A clone of the current set of TableSetInfos
      • getTableNames

        java.lang.String[] getTableNames​(java.lang.String dbSchemaName)
        Get the names of the tables that are accessible from this schema. Unlike most other "table" methods this one just returns real tables, not views etc.
        Parameters:
        dbSchemaName - The Schema
        Returns:
        An array of table names
      • getViewNames

        java.lang.String[] getViewNames​(java.lang.String dbSchemaName)
        Get the names of the views that are accessible from this schema.
        Parameters:
        dbSchemaName - The Schema
        Returns:
        An array of view names
      • tableExists

        boolean tableExists​(java.lang.String dbSchemaName,
                            java.lang.String table)
        Find out if this is a real table, view etc. in the database
        Parameters:
        dbSchemaName - The Schema
        table - The Table name
        Returns:
        True if table exists in the database
      • getTableInfo

        com.im.commons.db.ddl.DBTableInfo getTableInfo​(java.lang.String dbSchemaName,
                                                       java.lang.String name)
        Get the table info for the specified table or view.
        Parameters:
        dbSchemaName - The database schema
        name - The name of the table or view
        Returns:
        The table info object for the table or view
      • getTableInfoFull

        com.im.commons.db.ddl.DBTableInfo getTableInfoFull​(java.lang.String dbSchemaName,
                                                           java.lang.String name)
      • getTableInfoIgnoreCache

        com.im.commons.db.ddl.DBTableInfo getTableInfoIgnoreCache​(java.lang.String dbSchemaName,
                                                                  java.lang.String name,
                                                                  com.im.commons.progress.DFFeedback feedback)
      • getTableSetInfo

        com.im.commons.db.ddl.tablesets.TableSetInfo getTableSetInfo​(java.lang.String dbSchemaName,
                                                                     java.lang.String name,
                                                                     java.lang.String entityType)
        Get the table description for the table cluster. Usually a single table, but in some cases a set of tables that operate as a single unit e.g. JChemBase tables which have an associated *_UL table.
        Parameters:
        dbSchemaName - The Schema
        name - The Table or view name
        entityType - The type of entity
        Returns:
        The table description
      • getTableSetInfoFull

        com.im.commons.db.ddl.tablesets.TableSetInfo getTableSetInfoFull​(java.lang.String dbSchemaName,
                                                                         java.lang.String name,
                                                                         java.lang.String entityType)
      • updateColumnName

        com.im.commons.db.ddl.DBColInfo updateColumnName​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                         int tableIndex,
                                                         com.im.commons.db.ddl.DBColInfo colInfo,
                                                         java.lang.String columnName,
                                                         com.im.commons.progress.DFFeedback feedback)
      • updateColumnRequired

        @Deprecated
        com.im.commons.db.ddl.DBColInfo updateColumnRequired​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                             int tableIndex,
                                                             java.lang.String column,
                                                             java.lang.String nativeType,
                                                             java.lang.String columnDefinition,
                                                             java.lang.String defaultValue,
                                                             boolean required,
                                                             com.im.commons.progress.DFFeedback feedback)
        Deprecated.
      • updateColumnRequired

        com.im.commons.db.ddl.DBColInfo updateColumnRequired​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                             int tableIndex,
                                                             com.im.commons.db.ddl.DBColInfo colInfo,
                                                             boolean required,
                                                             com.im.commons.progress.DFFeedback feedback)
      • updateColumnDefault

        @Deprecated
        void updateColumnDefault​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                 int tableIndex,
                                 java.lang.String column,
                                 java.lang.Class columnClass,
                                 java.lang.String nativeType,
                                 java.lang.String columnDefinition,
                                 java.lang.String defaultValue,
                                 boolean required,
                                 com.im.commons.progress.DFFeedback feedback)
        Deprecated.
      • updateColumnDefault

        com.im.commons.db.ddl.DBColInfo updateColumnDefault​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                            int tableIndex,
                                                            com.im.commons.db.ddl.DBColInfo colInfo,
                                                            java.lang.String defaultValue,
                                                            com.im.commons.progress.DFFeedback feedback)
      • updateColumnDefinition

        @Deprecated
        void updateColumnDefinition​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                    int tableIndex,
                                    java.lang.String columnName,
                                    java.lang.String columnDefinition,
                                    com.im.commons.progress.DFFeedback feedback)
        Deprecated.
        Currently can only update the column size, so the name of this method is misleading
        Parameters:
        tSet -
        tableIndex -
        columnName -
        columnDefinition -
        feedback - The feedback for reporting operation progress, etc.
      • updateColumnDefinition

        com.im.commons.db.ddl.DBColInfo updateColumnDefinition​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                               int tableIndex,
                                                               com.im.commons.db.ddl.DBColInfo colInfo,
                                                               java.lang.String columnDefinition,
                                                               com.im.commons.progress.DFFeedback feedback)
        Currently can only update the column size, so the name of this method is misleading
        Parameters:
        tSet - The t able set
        tableIndex - The t able index in table set
        colInfo - The column to update
        columnDefinition - The new column defintion
        feedback - The feedback for reporting operation progress, etc.
        Returns:
        The DBColInfo
      • dropColumn

        void dropColumn​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                        int tableIndex,
                        java.lang.String columnName,
                        com.im.commons.progress.DFFeedback feedback)
      • dropTrigger

        void dropTrigger​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                         java.lang.String triggerName,
                         com.im.commons.progress.DFFeedback feedback)
      • dropSequence

        void dropSequence​(java.lang.String dbSchemaName,
                          java.lang.String sequenceName,
                          com.im.commons.progress.DFFeedback feedback)
      • dropTables

        void dropTables​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                        com.im.commons.progress.DFFeedback feedback)
        Drop this table, and any others that it uses
      • generateTableStatistics

        java.lang.String generateTableStatistics​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet)
      • updateTableName

        com.im.commons.db.ddl.tablesets.TableSetInfo updateTableName​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                                     java.lang.String newName,
                                                                     com.im.commons.progress.DFFeedback feedback)
      • addColumn

        com.im.commons.db.ddl.DBColInfo addColumn​(com.im.commons.db.ddl.tablesets.TableSetInfo tSet,
                                                  int tableIndex,
                                                  java.lang.String columnName,
                                                  java.lang.String colClass,
                                                  java.lang.String nativeType,
                                                  java.lang.String colDefinition,
                                                  java.lang.String colDefault,
                                                  boolean isNotNull,
                                                  com.im.commons.progress.DFFeedback feedback)
        Add a column to the main table
        Parameters:
        tSet - The table description
        tableIndex - The table to add the column to
        columnName - The new column name
        colClass - The class name of the columns data type e.g. java.lang.String
        nativeType - The column type e.g. VARCHAR
        colDefinition - The column definition e.g. VARCHAR(1000)
        colDefault - The column default value, or null
        isNotNull - Does the column allow null values
        feedback - The feedback for reporting operation progress, etc.
        Returns:
        The description of the added column
      • getIndexInfos

        java.util.List<com.im.commons.db.ddl.DBIndexInfo> getIndexInfos​(java.lang.String dbSchemaName,
                                                                        java.lang.String tableName)
        See index descriptions for this table
        Parameters:
        dbSchemaName - The schema
        tableName - The table name
        Returns:
        The list of index descriptions
      • getIndexInfo

        com.im.commons.db.ddl.DBIndexInfo getIndexInfo​(java.lang.String dbSchemaName,
                                                       java.lang.String indexName)
        Get the description for this index
        Parameters:
        dbSchemaName -
        indexName - The name of the index
        Returns:
        The description for this index
      • addIndex

        com.im.commons.db.ddl.DBIndexInfo addIndex​(java.lang.String schemaPlusIndexName,
                                                   java.lang.String indexType,
                                                   java.lang.String schemaPlusTableName,
                                                   java.util.List<java.lang.String> columns,
                                                   java.util.List<java.lang.Boolean> order,
                                                   com.im.commons.progress.DFFeedback feedback)
        Add an index to a table See DBIndexCapability for more information
        Parameters:
        schemaPlusIndexName - The schema qualified name for the new index
        indexType - The type of index. e.g. UNIQUE. Consult the DatabasePlatform.supportedIndexTypes() method to find out which types your DB supports. Can be null for a regular index.
        schemaPlusTableName - The schema qualified table to add the index to
        columns - A list of columns to use, in order.
        order - Order by ASC or DESC for each column. Must be the same number of elements as the columns argument.
      • addUniqueConstraint

        com.im.commons.db.ddl.DBConstraintInfo addUniqueConstraint​(java.lang.String dbSchemaName,
                                                                   java.lang.String table,
                                                                   java.lang.String constraintName,
                                                                   java.util.List<java.lang.String> columns,
                                                                   com.im.commons.progress.DFFeedback feedback)
      • dropUniqueConstraint

        void dropUniqueConstraint​(java.lang.String dbSchemaName,
                                  java.lang.String table,
                                  com.im.commons.db.ddl.DBConstraintInfo constraint,
                                  com.im.commons.progress.DFFeedback feedback)
      • addForeignKey

        com.im.commons.db.ddl.DBForeignKeyInfo addForeignKey​(java.lang.String fkName,
                                                             java.lang.String parentSchema,
                                                             java.lang.String parentTable,
                                                             java.lang.String dependentSchema,
                                                             java.lang.String dependentTable,
                                                             java.lang.String[] parentCols,
                                                             java.lang.String[] dependentCols,
                                                             java.lang.String onDeleteRule,
                                                             java.lang.String onUpdateRule)
      • rebuildIndex

        void rebuildIndex​(com.im.commons.db.ddl.DBIndexInfo index,
                          com.im.commons.progress.DFFeedback feedback)
        Rebuild this index
        Parameters:
        index -
        feedback - The feedback for reporting operation progress, etc.
      • dropIndex

        void dropIndex​(com.im.commons.db.ddl.DBIndexInfo index,
                       com.im.commons.progress.DFFeedback feedback)
        Drop this index
        Parameters:
        index -
        feedback - The feedback for reporting operation progress, etc.
      • addSequence

        com.im.commons.db.ddl.DBSequenceInfo addSequence​(java.lang.String dbSchemaName,
                                                         java.lang.String seqName,
                                                         com.im.commons.progress.DFFeedback feedback)
        Add the specified sequence
        Parameters:
        seqName -
      • createStandardTable

        com.im.commons.db.ddl.tablesets.TableSetInfo createStandardTable​(java.lang.String dbSchemaName,
                                                                         java.lang.String tableName,
                                                                         java.lang.String idColumnName,
                                                                         java.lang.String extraCols,
                                                                         com.im.commons.progress.DFFeedback feedback)
      • createGenericTable

        com.im.commons.db.ddl.tablesets.TableSetInfo createGenericTable​(java.lang.String dbSchemaName,
                                                                        java.lang.String tableName,
                                                                        java.util.List<com.im.commons.db.ddl.DBDatabaseInfo.NativeType> columnDefs,
                                                                        java.util.List<java.lang.String> columnNames,
                                                                        com.im.commons.progress.DFFeedback feedback)
      • createView

        com.im.commons.db.ddl.tablesets.TableSetInfo createView​(java.lang.String dbSchemaName,
                                                                java.lang.String viewName,
                                                                java.lang.String viewDefSQL,
                                                                com.im.commons.progress.DFFeedback feedback)
      • createInlineView

        com.im.commons.db.ddl.tablesets.TableSetInfo createInlineView​(java.lang.String dbSchemaName,
                                                                      java.lang.String viewName,
                                                                      java.lang.String primaryKeyColumnName,
                                                                      java.lang.String sql,
                                                                      com.im.commons.progress.DFFeedback feedback)
      • getConstraintNames

        com.im.commons.db.util.SchemaQualifiedName[] getConstraintNames()
      • dropForeignKeyConstraint

        void dropForeignKeyConstraint​(com.im.commons.db.ddl.DBForeignKeyInfo foreingKeyInfo,
                                      com.im.commons.progress.DFFeedback feedback)