- java.lang.Object
-
- org.tentackle.sql.metadata.ForeignKeyMetaData
-
public class ForeignKeyMetaData extends java.lang.ObjectMeta 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(java.lang.Object obj)ForeignKeyActiongetDeleteRule()Gets the delete rule.java.util.List<ForeignKeyColumnMetaData>getForeignKeyColumns()Gets the columns.java.lang.StringgetForeignKeyName()Gets the name of the foreign key.java.lang.StringgetForeignKeySchema()Geths the schema of the referencing column.java.lang.StringgetForeignKeyTable()Gets the referencing table.java.lang.StringgetFullForeignKeyTableName()Gets the full foreign key tablename including optional schema.java.lang.StringgetFullPrimaryKeyTableName()Gets the full primary key tablename including optional schema.java.lang.StringgetPrimaryKeySchema()Gets the schema of the referenced column.java.lang.StringgetPrimaryKeyTable()Gets the referenced table.TableMetaDatagetTableMetaData()Gets the table this foreign key belongs to.ForeignKeyActiongetUpdateRule()Gets the update rule.inthashCode()voidsetForeignKeyTable(java.lang.String foreignKeyTable)Updates the foreign table name.
This is necessary, if a table was renamed.voidsetPrimaryKeyTable(java.lang.String primaryKeyTable)Updates the primary table name.
This is necessary, if a table was renamed.voidsetupForeignKeyFromMetaData(java.sql.ResultSet resultSet)Sets up the foreign key from the database meta data result.java.lang.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 java.util.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 java.lang.String getForeignKeyName()
Gets the name of the foreign key.- Returns:
- the fk name
-
getForeignKeySchema
public java.lang.String getForeignKeySchema()
Geths the schema of the referencing column.- Returns:
- the referencing schema, null if default
-
getForeignKeyTable
public java.lang.String getForeignKeyTable()
Gets the referencing table.- Returns:
- the table name
-
getFullForeignKeyTableName
public java.lang.String getFullForeignKeyTableName()
Gets the full foreign key tablename including optional schema.- Returns:
- the full tablename
-
getPrimaryKeySchema
public java.lang.String getPrimaryKeySchema()
Gets the schema of the referenced column.- Returns:
- the referenced schema, null if default
-
getPrimaryKeyTable
public java.lang.String getPrimaryKeyTable()
Gets the referenced table.- Returns:
- the table name
-
getFullPrimaryKeyTableName
public java.lang.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(java.sql.ResultSet resultSet) throws java.sql.SQLExceptionSets up the foreign key from the database meta data result.- Parameters:
resultSet- the foreign key column result set- Throws:
java.sql.SQLException- the processing the result set failed
-
setPrimaryKeyTable
public void setPrimaryKeyTable(java.lang.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(java.lang.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.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-