Class TableMetaData
java.lang.Object
org.tentackle.sql.metadata.TableMetaData
Database metadata for a table that is part of the model.
- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionTableMetaData(ModelMetaData modelMetaData, String modelTableName) Creates a table metadata instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetColumnByName(String columnName) Gets a column by its column name.Gets the metadata for columns.Gets the comment.Gets the foreign keys.Gets the database table name with optional schema name prepended.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).Gets the metadata for indexes.Gets the model this table belongs to.Gets the table name used in the model.Gets the database schema name.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).Gets the database table name.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).inthashCode()voidsetComment(String comment) Sets the comment.voidsetupTableFromMetaData(DatabaseMetaData metaData, String[] schemas, String schemaPattern, String tablePattern) Sets up the table, its columns, indexes and foreign keys from the database metadata.toString()voidvalidate()Validates and post-processes the table data.
-
Constructor Details
-
TableMetaData
Creates a table metadata instance.- Parameters:
modelMetaData- the model this table belongs tomodelTableName- the table name used in the model
-
-
Method Details
-
setupTableFromMetaData
public void setupTableFromMetaData(DatabaseMetaData metaData, String[] schemas, String schemaPattern, String tablePattern) throws SQLException Sets up the table, its columns, indexes and foreign keys from the database metadata.The method is idempotent: any state left over from a previous attempt is discarded. This is essential because the caller retries with different name patterns and metadata sources until the table is found (see
Backend#getTableMetaData), and a failed attempt may already have collected some columns.- Parameters:
metaData- the database metadataschemas- valid schemas to scan, null if allschemaPattern- the schema (null if none, "" if without schema)tablePattern- the table pattern- Throws:
SQLException- if processing the metadata failedBackendException- if the metadata is inconsistent
-
getModelMetaData
-
getModelTableName
Gets the table name used in the model.- Returns:
- the model's table name
-
getSchemaName
Gets the database schema name.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).- Returns:
- the schema, null if none
-
getTableName
Gets the database table name.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).- Returns:
- the table name (without schema)
-
getFullTableName
Gets the database table name with optional schema name prepended.
The name is returned as reported by the database, which may be uppercase (Oracle, for example).- Returns:
- the full table name
-
getComment
-
setComment
Sets the comment.- Parameters:
comment- the comment, null if none
-
getColumns
-
getColumnByName
Gets a column by its column name.- Parameters:
columnName- the column name- Returns:
- the column, null if no such column
-
getIndexes
-
getForeignKeys
Gets the foreign keys.- Returns:
- the foreign keys
-
validate
public void validate()Validates and post-processes the table data. -
hashCode
-
equals
-
toString
-