Class ForeignKey

java.lang.Object
org.hibernate.mapping.Constraint
org.hibernate.mapping.ForeignKey
All Implemented Interfaces:
Serializable, Exportable

public class ForeignKey extends Constraint
A mapping model object representing a foreign key constraint.
See Also:
  • Constructor Details

    • ForeignKey

      public ForeignKey()
  • Method Details

    • getExportIdentifier

      public String getExportIdentifier()
      Description copied from interface: Exportable
      Get a unique identifier to make sure we are not exporting the same database structure multiple times.
      Returns:
      The exporting identifier.
    • disableCreation

      public void disableCreation()
    • isCreationEnabled

      public boolean isCreationEnabled()
    • setName

      public void setName(String name)
      Overrides:
      setName in class Constraint
    • sqlConstraintString

      @Deprecated(since="6.2", forRemoval=true) public String sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      sqlConstraintString in class Constraint
    • getReferencedTable

      public Table getReferencedTable()
    • setReferencedTable

      public void setReferencedTable(Table referencedTable) throws MappingException
      Throws:
      MappingException
    • alignColumns

      public void alignColumns()
      Validates that column span of the foreign key and the primary key is the same.

      Furthermore it aligns the length of the underlying tables columns.

    • getReferencedEntityName

      public String getReferencedEntityName()
    • setReferencedEntityName

      public void setReferencedEntityName(String referencedEntityName)
    • getKeyDefinition

      public String getKeyDefinition()
    • setKeyDefinition

      public void setKeyDefinition(String keyDefinition)
    • setOnDeleteAction

      public void setOnDeleteAction(OnDeleteAction onDeleteAction)
    • getOnDeleteAction

      public OnDeleteAction getOnDeleteAction()
    • isCascadeDeleteEnabled

      @Deprecated(since="6.2") public boolean isCascadeDeleteEnabled()
      Deprecated.
    • setCascadeDeleteEnabled

      @Deprecated(since="6.2") public void setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
    • isPhysicalConstraint

      public boolean isPhysicalConstraint()
    • getReferencedColumns

      public List<Column> getReferencedColumns()
      Returns the referenced columns if the foreignkey does not refer to the primary key
    • isReferenceToPrimaryKey

      public boolean isReferenceToPrimaryKey()
      Does this foreignkey reference the primary key of the reference table
    • addReferencedColumns

      public void addReferencedColumns(List<Column> referencedColumns)
    • toString

      public String toString()
      Overrides:
      toString in class Constraint
    • generatedConstraintNamePrefix

      @Deprecated(forRemoval=true) public String generatedConstraintNamePrefix()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      generatedConstraintNamePrefix in class Constraint
      Returns:
      String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".
    • resolveReferencedClass

      @Internal public PersistentClass resolveReferencedClass(Metadata metadata)