Package com.im.commons.db.ddl
Interface DBTableInfo
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
DBTableInfoImpl
,DBTableInfoProxy
public interface DBTableInfo extends java.io.Serializable
Database info class for a database table. The term table is used in a generic sense meaning any database artifact that can behave in a tabular fashion, and includes views (and in future synonyms, materialised views etc.). All of these will have some things like a name, columns but the different sub-types will differ in some respects e.g. views have SQL that define the view whereas plain tables so not. The properties of this class are a superset of all the properties and not all will be used for any particular sub-type. Note: this class may be refactored in future be better distinguish the different sub-types.- Author:
- Tim Dudgeon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DBTableInfo.Type
The types ofDBTableInfo
s.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBTableInfo
copy()
Creates a duplicate copy of thisDBTableInfo
instance.DBConstraintInfo
findUniqueConstraintNameForColumns(java.lang.String[] columns)
Retrieves constraint name for the named columns.DBColInfo
getColumn(java.lang.String name)
Finds aDBColInfo
by its name.java.util.List<DBColInfo>
getColumns()
Gets the columns in thisDBTableInfo
.java.util.List<DBForeignKeyInfo>
getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table).java.util.List<DBForeignKeyInfo>
getImportedFKInfo()
Get the foreign keys that this table defines.java.util.List<DBIndexInfo>
getIndexInfo()
java.lang.String
getName()
Gets the name of the database artefact represented by thisDBTableInfo
.java.util.List<java.lang.String>
getPrimaryKeyColumns()
Gets the name of the primary key columns.java.lang.String
getSchema()
Gets the database schema name of the associated artefact.java.lang.String
getSQL()
Gets the SQL select statement if this is aDBTableInfo.Type.VIEW
.java.util.List<DBTriggerInfo>
getTriggerInfo()
DBTableInfo.Type
getType()
Gets the type of thisDBTableInfo
instance.java.util.List<DBConstraintInfo>
getUniqueConstraints()
boolean
isReadOnly()
Determines whether this database artifact allows modifications.java.lang.String
schemaPlusTable()
Gets the fully qualified name of the underlying database artifact.DBTableInfo
updateColumns(java.util.List<DBColInfo> cols)
DBTableInfo
updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
DBTableInfo
updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
DBTableInfo
updateIndexInfos(java.util.List<DBIndexInfo> indexes)
DBTableInfo
updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-
-
Method Detail
-
getType
DBTableInfo.Type getType()
Gets the type of thisDBTableInfo
instance.- Returns:
- This
DBTableInfo
's type.
-
getName
java.lang.String getName()
Gets the name of the database artefact represented by thisDBTableInfo
.- Returns:
- The database artifact's name.
-
getSchema
java.lang.String getSchema()
Gets the database schema name of the associated artefact.- Returns:
- The database artifact's schema name. This can return
null
if the database does not use the concept of schemas.
-
schemaPlusTable
java.lang.String schemaPlusTable()
Gets the fully qualified name of the underlying database artifact.- Returns:
- The concatenated form of
getName()
andgetSchema()
.
-
getSQL
java.lang.String getSQL()
Gets the SQL select statement if this is aDBTableInfo.Type.VIEW
.- Returns:
- The SQL select string or
null
.
-
isReadOnly
boolean isReadOnly()
Determines whether this database artifact allows modifications.- Returns:
true
if this database artifact is readonly and cannot be modified.
-
copy
DBTableInfo copy()
Creates a duplicate copy of thisDBTableInfo
instance.- Returns:
- A new
DBTableInfo
instance.
-
findUniqueConstraintNameForColumns
DBConstraintInfo findUniqueConstraintNameForColumns(java.lang.String[] columns)
Retrieves constraint name for the named columns. The method will return name of the unique constraint for the given set of columns. The constraint name may beDatabasePlatform.NAME_PRIMARY_KEY_CONSTRAINT
, which may be handled differently in some databases - for drop, useDatabasePlatform.sqlDropPrimaryConstraint(String, String, String[])
.- Parameters:
columns
- DB columns- Returns:
- The constraint, or
null
if there's no unique constraint.
-
getColumn
DBColInfo getColumn(java.lang.String name)
Finds aDBColInfo
by its name. This will search through the columns in thisDBTableInfo
for a column with the required name.- Parameters:
name
- The name of the column to find.- Returns:
- The
DBColInfo
with the required name ornull
if no such column exists.
-
getColumns
java.util.List<DBColInfo> getColumns()
Gets the columns in thisDBTableInfo
.- Returns:
- The list of columns.
-
getExportedFKInfo
java.util.List<DBForeignKeyInfo> getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table). e.g. the keys in this table that are referred to in a foreign key constraint definition somewhere.- Returns:
- A list of foreign keys
-
getImportedFKInfo
java.util.List<DBForeignKeyInfo> getImportedFKInfo()
Get the foreign keys that this table defines. e.g. the primary keys of other tables (or possibly this table) that are referred to in a foreign key constraint definition.- Returns:
- A list of foreign keys
-
getIndexInfo
java.util.List<DBIndexInfo> getIndexInfo()
-
getPrimaryKeyColumns
java.util.List<java.lang.String> getPrimaryKeyColumns()
Gets the name of the primary key columns.- Returns:
- The primary key column names. It can return an empty list, but not
null
.
-
getTriggerInfo
java.util.List<DBTriggerInfo> getTriggerInfo()
-
getUniqueConstraints
java.util.List<DBConstraintInfo> getUniqueConstraints()
-
updateColumns
DBTableInfo updateColumns(java.util.List<DBColInfo> cols)
-
updateImportedForeignKeys
DBTableInfo updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
-
updateExportedForeignKeys
DBTableInfo updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
-
updateIndexInfos
DBTableInfo updateIndexInfos(java.util.List<DBIndexInfo> indexes)
-
updateUniqueConstraintInfos
DBTableInfo updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-