Class ForeignKeyMetaData


  • public class ForeignKeyMetaData
    extends java.lang.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 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.SQLException
        Sets 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:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object