Class ForeignKeyMetaData


  • public class ForeignKeyMetaData
    extends Object
    Meta data for foreign keys.

    Tentackle uses foreign keys only for simple columns (ID).

    Author:
    harald
    • 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.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object