Package org.hibernate.mapping
Class ForeignKey
- java.lang.Object
-
- org.hibernate.mapping.Constraint
-
- org.hibernate.mapping.ForeignKey
-
- All Implemented Interfaces:
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 voidaddReferencedColumns(Iterator referencedColumnsIterator)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()ListgetReferencedColumns()Returns the referenced columns if the foreignkey does not refer to the primary keyStringgetReferencedEntityName()TablegetReferencedTable()booleanisCascadeDeleteEnabled()booleanisCreationEnabled()booleanisPhysicalConstraint()booleanisReferenceToPrimaryKey()Does this foreignkey reference the primary key of the reference tablevoidsetCascadeDeleteEnabled(boolean cascadeDeleteEnabled)voidsetKeyDefinition(String keyDefinition)voidsetName(String name)voidsetReferencedEntityName(String referencedEntityName)voidsetReferencedTable(Table referencedTable)StringsqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)StringsqlDropString(SqlStringGenerationContext context, String defaultCatalog, String defaultSchema)StringtoString()-
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 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
public String sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)
- 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)
-
sqlDropString
public String sqlDropString(SqlStringGenerationContext context, String defaultCatalog, String defaultSchema)
- Specified by:
sqlDropStringin interfaceRelationalModel- Overrides:
sqlDropStringin classConstraint
-
isCascadeDeleteEnabled
public boolean isCascadeDeleteEnabled()
-
setCascadeDeleteEnabled
public void setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
-
isPhysicalConstraint
public boolean isPhysicalConstraint()
-
getReferencedColumns
public 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(Iterator referencedColumnsIterator)
-
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_".
-
-