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 void
addReferencedColumns(List<Column> referencedColumns)
void
alignColumns()
Validates that column span of the foreign key and the primary key is the same.void
disableCreation()
String
generatedConstraintNamePrefix()
Deprecated, for removal: This API element is subject to removal in a future version.String
getExportIdentifier()
Get a unique identifier to make sure we are not exporting the same database structure multiple times.String
getKeyDefinition()
OnDeleteAction
getOnDeleteAction()
List<Column>
getReferencedColumns()
Returns the referenced columns if the foreignkey does not refer to the primary keyString
getReferencedEntityName()
Table
getReferencedTable()
boolean
isCascadeDeleteEnabled()
Deprecated.boolean
isCreationEnabled()
boolean
isPhysicalConstraint()
boolean
isReferenceToPrimaryKey()
Does this foreignkey reference the primary key of the reference tablePersistentClass
resolveReferencedClass(Metadata metadata)
void
setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
Deprecated.void
setKeyDefinition(String keyDefinition)
void
setName(String name)
void
setOnDeleteAction(OnDeleteAction onDeleteAction)
void
setReferencedEntityName(String referencedEntityName)
void
setReferencedTable(Table referencedTable)
String
sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)
Deprecated, for removal: This API element is subject to removal in a future version.String
toString()
-
Methods inherited from class org.hibernate.mapping.Constraint
addColumn, addColumns, containsColumn, generateName, generateName, getColumn, getColumns, getColumnSpan, getName, getTable, hashedName, isGenerated, setTable
-
-
-
-
Method Detail
-
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 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:
sqlConstraintString
in 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:
toString
in classConstraint
-
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 classConstraint
- Returns:
- String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".
-
resolveReferencedClass
@Internal public PersistentClass resolveReferencedClass(Metadata metadata)
-
-