Class ForeignKeyMetaData

java.lang.Object
org.tentackle.sql.metadata.ForeignKeyMetaData

public class ForeignKeyMetaData extends Object
Metadata for foreign keys.

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

Author:
harald
  • Constructor Details

    • ForeignKeyMetaData

      public ForeignKeyMetaData(TableMetaData tableMetaData)
      Creates foreign key meta data.
      Parameters:
      tableMetaData - the table this foreign key belongs to
  • Method Details

    • addForeignKeyColumn

      public void addForeignKeyColumn(ForeignKeyColumnMetaData column)
      Adds a column to the foreign key.
      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 foreign key name
    • getForeignKeySchema

      public String getForeignKeySchema()
      Gets 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 metadata 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 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

      public void setForeignKeyTable(String foreignKeyTable)
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object