org.hibernate.mapping
Class ForeignKey

java.lang.Object
  extended by org.hibernate.mapping.Constraint
      extended by org.hibernate.mapping.ForeignKey
All Implemented Interfaces:
Serializable, RelationalModel

public class ForeignKey
extends Constraint

A foreign key constraint

See Also:
Serialized Form

Constructor Summary
ForeignKey()
           
 
Method Summary
 void addReferencedColumns(Iterator referencedColumnsIterator)
           
 void alignColumns()
          Validates that columnspan of the foreignkey and the primarykey is the same.
 String generatedConstraintNamePrefix()
           
 List getReferencedColumns()
          Returns the referenced columns if the foreignkey does not refer to the primary key
 String getReferencedEntityName()
           
 Table getReferencedTable()
           
 boolean isCascadeDeleteEnabled()
           
 boolean isPhysicalConstraint()
           
 boolean isReferenceToPrimaryKey()
          Does this foreignkey reference the primary key of the reference table
 void setCascadeDeleteEnabled(boolean cascadeDeleteEnabled)
           
 void setReferencedEntityName(String referencedEntityName)
           
 void setReferencedTable(Table referencedTable)
           
 String sqlConstraintString(Dialect dialect, String constraintName, String defaultCatalog, String defaultSchema)
           
 String sqlDropString(Dialect dialect, String defaultCatalog, String defaultSchema)
           
 String toString()
           
 
Methods inherited from class org.hibernate.mapping.Constraint
addColumn, addColumns, columnIterator, containsColumn, generateName, generateName, getColumn, getColumnIterator, getColumns, getColumnSpan, getName, getTable, hashedName, isGenerated, setName, setTable, sqlCreateString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForeignKey

public ForeignKey()
Method Detail

sqlConstraintString

public String sqlConstraintString(Dialect dialect,
                                  String constraintName,
                                  String defaultCatalog,
                                  String defaultSchema)
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 columnspan of the foreignkey and the primarykey is the same. Furthermore it aligns the length of the underlying tables columns.


getReferencedEntityName

public String getReferencedEntityName()

setReferencedEntityName

public void setReferencedEntityName(String referencedEntityName)

sqlDropString

public String sqlDropString(Dialect dialect,
                            String defaultCatalog,
                            String defaultSchema)
Specified by:
sqlDropString in interface RelationalModel
Overrides:
sqlDropString in class Constraint

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:
toString in class Constraint

generatedConstraintNamePrefix

public String generatedConstraintNamePrefix()
Specified by:
generatedConstraintNamePrefix in class Constraint
Returns:
String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.