Package org.hibernate.mapping
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ForeignKey()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddReferencedColumns(List<Column> referencedColumns)voidalignColumns()Validates that column span of the foreign key and the primary key is the same.voiddisableCreation()StringgeneratedConstraintNamePrefix()StringgetExportIdentifier()Get a unique identifier to make sure we are not exporting the same database structure multiple times.StringgetKeyDefinition()OnDeleteActiongetOnDeleteAction()List<Column>getReferencedColumns()Returns the referenced columns if the foreignkey does not refer to the primary keyStringgetReferencedEntityName()TablegetReferencedTable()booleanisCascadeDeleteEnabled()Deprecated.booleanisCreationEnabled()booleanisPhysicalConstraint()booleanisReferenceToPrimaryKey()Does this foreignkey reference the primary key of the reference tablevoidsetCascadeDeleteEnabled(boolean cascadeDeleteEnabled)Deprecated.voidsetKeyDefinition(String keyDefinition)voidsetName(String name)voidsetOnDeleteAction(OnDeleteAction onDeleteAction)voidsetReferencedEntityName(String referencedEntityName)voidsetReferencedTable(Table referencedTable)StringsqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)Deprecated, for removal: This API element is subject to removal in a future version.StringtoString()-
Methods inherited from class org.hibernate.mapping.Constraint
addColumn, addColumns, containsColumn, generateName, generateName, getColumn, getColumnIterator, getColumns, getColumnSpan, getName, getTable, hashedName, isGenerated, setTable
-
-
-
-
Method Detail
-
getExportIdentifier
public String getExportIdentifier()
Description copied from interface:ExportableGet 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:
setNamein classConstraint
-
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:
sqlConstraintStringin classConstraint
-
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)
Deprecated.
-
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
-
toString
public String toString()
- Overrides:
toStringin classConstraint
-
generatedConstraintNamePrefix
public String generatedConstraintNamePrefix()
- Specified by:
generatedConstraintNamePrefixin classConstraint- Returns:
- String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".
-
-