java.lang.Object
org.tentackle.sql.metadata.ForeignKeyMetaData
Metadata for foreign keys.
Tentackle uses foreign keys only for simple columns (ID).
- Author:
- harald
-
Constructor Summary
ConstructorsConstructorDescriptionForeignKeyMetaData(TableMetaData tableMetaData) Creates foreign key meta data. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a column to the foreign key.booleanGets the delete-rule.Gets the columns.Gets the name of the foreign key.Gets the schema of the referencing column.Gets the referencing table.Gets the full foreign key tablename including optional schema.Gets the full primary key tablename including optional schema.Gets the schema of the referenced column.Gets the referenced table.Gets the table this foreign key belongs to.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 metadata result.toString()voidvalidate()Validates and post-processes the foreign key data.
-
Constructor Details
-
ForeignKeyMetaData
Creates foreign key meta data.- Parameters:
tableMetaData- the table this foreign key belongs to
-
-
Method Details
-
addForeignKeyColumn
Adds a column to the foreign key.- Parameters:
column- the column
-
getForeignKeyColumns
Gets the columns.- Returns:
- the columns ordered by position
-
getTableMetaData
Gets the table this foreign key belongs to.- Returns:
- the table
-
getForeignKeyName
Gets the name of the foreign key.- Returns:
- the foreign key name
-
getForeignKeySchema
Gets the schema of the referencing column.- Returns:
- the referencing schema, null if default
-
getForeignKeyTable
Gets the referencing table.- Returns:
- the table name
-
getFullForeignKeyTableName
Gets the full foreign key tablename including optional schema.- Returns:
- the full tablename
-
getPrimaryKeySchema
Gets the schema of the referenced column.- Returns:
- the referenced schema, null if default
-
getPrimaryKeyTable
Gets the referenced table.- Returns:
- the table name
-
getFullPrimaryKeyTableName
Gets the full primary key tablename including optional schema.- Returns:
- the full tablename
-
getUpdateRule
Gets the update-rule.- Returns:
- the update-rule
-
getDeleteRule
Gets the delete-rule.- Returns:
- the delete-rule
-
setupForeignKeyFromMetaData
Sets up the foreign key from the database metadata result.- Parameters:
resultSet- the foreign key column result set- Throws:
SQLException- the processing the result set failed
-
setPrimaryKeyTable
Updates the primary table name.
This is necessary, if a table was renamed. The metadata 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
Updates the foreign table name.
This is necessary, if a table was renamed. The metadata 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 post-processes the foreign key data. -
hashCode
public int hashCode() -
equals
-
toString
-