- java.lang.Object
-
- org.tentackle.sql.metadata.ForeignKeyMetaData
-
public class ForeignKeyMetaData extends Object
Meta data for foreign keys.Tentackle uses foreign keys only for simple columns (ID).
- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description ForeignKeyMetaData(TableMetaData tableMetaData)Creates foreign key meta data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddForeignKeyColumn(ForeignKeyColumnMetaData column)Adds a column to the fk.booleanequals(Object obj)ForeignKeyActiongetDeleteRule()Gets the delete rule.List<ForeignKeyColumnMetaData>getForeignKeyColumns()Gets the columns.StringgetForeignKeyName()Gets the name of the foreign key.StringgetForeignKeySchema()Geths the schema of the referencing column.StringgetForeignKeyTable()Gets the referencing table.StringgetFullForeignKeyTableName()Gets the full foreign key tablename including optional schema.StringgetFullPrimaryKeyTableName()Gets the full primary key tablename including optional schema.StringgetPrimaryKeySchema()Gets the schema of the referenced column.StringgetPrimaryKeyTable()Gets the referenced table.TableMetaDatagetTableMetaData()Gets the table this foreign key belongs to.ForeignKeyActiongetUpdateRule()Gets the update rule.inthashCode()voidsetForeignKeyTable(String foreignKeyTable)Updates the foreign table name.
This is necessary, if a table was renamed.voidsetPrimaryKeyTable(String primaryKeyTable)Updates the primary table name.
This is necessary, if a table was renamed.voidsetupForeignKeyFromMetaData(ResultSet resultSet)Sets up the foreign key from the database meta data result.StringtoString()voidvalidate()Validates and postprocesses the foreign key data.
-
-
-
Constructor Detail
-
ForeignKeyMetaData
public ForeignKeyMetaData(TableMetaData tableMetaData)
Creates foreign key meta data.- Parameters:
tableMetaData- the tablethis fk belongs to
-
-
Method Detail
-
addForeignKeyColumn
public void addForeignKeyColumn(ForeignKeyColumnMetaData column)
Adds a column to the fk.- Parameters:
column- the column
-
getForeignKeyColumns
public List<ForeignKeyColumnMetaData> getForeignKeyColumns()
Gets the columns.- Returns:
- the columns ordered by position
-
getTableMetaData
public TableMetaData getTableMetaData()
Gets the table this foreign key belongs to.- Returns:
- the table
-
getForeignKeyName
public String getForeignKeyName()
Gets the name of the foreign key.- Returns:
- the fk name
-
getForeignKeySchema
public String getForeignKeySchema()
Geths the schema of the referencing column.- Returns:
- the referencing schema, null if default
-
getForeignKeyTable
public String getForeignKeyTable()
Gets the referencing table.- Returns:
- the table name
-
getFullForeignKeyTableName
public String getFullForeignKeyTableName()
Gets the full foreign key tablename including optional schema.- Returns:
- the full tablename
-
getPrimaryKeySchema
public String getPrimaryKeySchema()
Gets the schema of the referenced column.- Returns:
- the referenced schema, null if default
-
getPrimaryKeyTable
public String getPrimaryKeyTable()
Gets the referenced table.- Returns:
- the table name
-
getFullPrimaryKeyTableName
public String getFullPrimaryKeyTableName()
Gets the full primary key tablename including optional schema.- Returns:
- the full tablename
-
getUpdateRule
public ForeignKeyAction getUpdateRule()
Gets the update rule.- Returns:
- the update rule
-
getDeleteRule
public ForeignKeyAction getDeleteRule()
Gets the delete rule.- Returns:
- the delete rule
-
setupForeignKeyFromMetaData
public void setupForeignKeyFromMetaData(ResultSet resultSet) throws SQLException
Sets up the foreign key from the database meta data result.- Parameters:
resultSet- the foreign key column result set- Throws:
SQLException- the processing the result set failed
-
setPrimaryKeyTable
public void setPrimaryKeyTable(String primaryKeyTable)
Updates the primary table name.
This is necessary, if a table was renamed. The meta data then still holds the old tablename. However, after a RENAME TABLE the foreign keys will be updated by the database automatically, so there's no need to drop and re-create the FK.- Parameters:
primaryKeyTable- the new primary table name
-
setForeignKeyTable
public void setForeignKeyTable(String foreignKeyTable)
Updates the foreign table name.
This is necessary, if a table was renamed. The meta data then still holds the old tablename. However, after a RENAME TABLE the foreign keys will be updated by the database automatically, so there's no need to drop and re-create the FK.- Parameters:
foreignKeyTable- the foreign key table name
-
validate
public void validate()
Validates and postprocesses the foreign key data.
-
-