Package org.hibernate.mapping
Class ForeignKey
- java.lang.Object
-
- org.hibernate.mapping.Constraint
-
- org.hibernate.mapping.ForeignKey
-
- All Implemented Interfaces:
java.io.Serializable
,Exportable
,RelationalModel
public class ForeignKey extends Constraint
A foreign key constraint- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ForeignKey()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addReferencedColumns(java.util.Iterator referencedColumnsIterator)
void
alignColumns()
Validates that column span of the foreign key and the primary key is the same.void
disableCreation()
java.lang.String
generatedConstraintNamePrefix()
java.lang.String
getExportIdentifier()
Get a unique identifier to make sure we are not exporting the same database structure multiple times.java.lang.String
getKeyDefinition()
java.util.List
getReferencedColumns()
Returns the referenced columns if the foreignkey does not refer to the primary keyjava.lang.String
getReferencedEntityName()
Table
getReferencedTable()
boolean
isCascadeDeleteEnabled()
boolean
isCreationEnabled()
boolean
isPhysicalConstraint()
boolean
isReferenceToPrimaryKey()
Does this foreignkey reference the primary key of the reference tablevoid
setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
void
setKeyDefinition(java.lang.String keyDefinition)
void
setName(java.lang.String name)
void
setReferencedEntityName(java.lang.String referencedEntityName)
void
setReferencedTable(Table referencedTable)
java.lang.String
sqlConstraintString(SqlStringGenerationContext context, java.lang.String constraintName, java.lang.String defaultCatalog, java.lang.String defaultSchema)
java.lang.String
sqlDropString(SqlStringGenerationContext context, java.lang.String defaultCatalog, java.lang.String defaultSchema)
java.lang.String
toString()
-
Methods inherited from class org.hibernate.mapping.Constraint
addColumn, addColumns, columnIterator, containsColumn, generateName, generateName, getColumn, getColumnIterator, getColumns, getColumnSpan, getName, getTable, hashedName, isGenerated, setTable, sqlCreateString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hibernate.mapping.RelationalModel
sqlCreateString, sqlDropString
-
-
-
-
Method Detail
-
getExportIdentifier
public java.lang.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(java.lang.String name)
- Overrides:
setName
in classConstraint
-
sqlConstraintString
public java.lang.String sqlConstraintString(SqlStringGenerationContext context, java.lang.String constraintName, java.lang.String defaultCatalog, java.lang.String defaultSchema)
- 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 java.lang.String getReferencedEntityName()
-
setReferencedEntityName
public void setReferencedEntityName(java.lang.String referencedEntityName)
-
getKeyDefinition
public java.lang.String getKeyDefinition()
-
setKeyDefinition
public void setKeyDefinition(java.lang.String keyDefinition)
-
sqlDropString
public java.lang.String sqlDropString(SqlStringGenerationContext context, java.lang.String defaultCatalog, java.lang.String defaultSchema)
- Specified by:
sqlDropString
in interfaceRelationalModel
- Overrides:
sqlDropString
in classConstraint
-
isCascadeDeleteEnabled
public boolean isCascadeDeleteEnabled()
-
setCascadeDeleteEnabled
public void setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
-
isPhysicalConstraint
public boolean isPhysicalConstraint()
-
getReferencedColumns
public java.util.List 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(java.util.Iterator referencedColumnsIterator)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classConstraint
-
generatedConstraintNamePrefix
public java.lang.String generatedConstraintNamePrefix()
- Specified by:
generatedConstraintNamePrefix
in classConstraint
- Returns:
- String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".
-
-