Class ForeignKeyConstraintDescriptor
java.lang.Object
org.apache.derby.iapi.sql.dictionary.TupleDescriptor
org.apache.derby.iapi.sql.dictionary.UniqueTupleDescriptor
org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor
org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor
org.apache.derby.iapi.sql.dictionary.ForeignKeyConstraintDescriptor
- All Implemented Interfaces:
Dependable, Dependent, Provider
A foreign key.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) int(package private) ReferencedKeyConstraintDescriptorinterface to this descriptor public ReferencedKeyConstraintDescriptor getReferencedConstraint() throws StandardException; public UUID getReferencedConstraintId() throws StandardException; public boolean isSelfReferencingFK() throws StandardException;(package private) UUIDFields inherited from class KeyConstraintDescriptor
indexIdFields inherited from class ConstraintDescriptor
ALL, constraintId, constraintName, DISABLED, ENABLED, SYSCONSTRAINTS_STATE_FIELD, tableFields inherited from interface Dependable
ACTIVATION, ALIAS, COLUMNS_IN_TABLE, COLUMNS_PERMISSION, CONGLOMERATE, CONSTRAINT, DEFAULT, FILE, HEAP, INDEX, PERM, PREPARED_STATEMENT, ROLE_GRANT, ROUTINE_PERMISSION, SCHEMA, SEQUENCE, STORED_PREPARED_STATEMENT, TABLE, TABLE_PERMISSION, TRIGGER, VIEW -
Constructor Summary
ConstructorsModifierConstructorDescription(package private)ForeignKeyConstraintDescriptor(DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] fkColumns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, UUID referencedConstraintId, boolean enforced, int raDeleteRule, int raUpdateRule) Constructor for a ForeignKeyConstraintDescriptorprotectedForeignKeyConstraintDescriptor(DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] fkColumns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, ReferencedKeyConstraintDescriptor referencedConstraintDescriptor, boolean enforced, int raDeleteRule, int raUpdateRule) Constructor for a ForeignKeyConstraintDescriptor -
Method Summary
Modifier and TypeMethodDescriptionintGets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).intGets a referential action rule on a DELETEintGets a referential action rule on a UPDATEGet the constraint that this FK references.Get the constraint id for the constraint that this FK references.booleanAm I a self-referencing FK?booleanneedsToFire(int stmtType, int[] modifiedCols) Does this constraint need to fire on this type of DML?Methods inherited from class KeyConstraintDescriptor
getConglomerateId, getIndexConglomerateDescriptor, getIndexId, getIndexUUIDString, hasBackingIndex, toStringMethods inherited from class ConstraintDescriptor
areColumnsComparable, columnIntersects, deferrable, doColumnsIntersect, drop, enforced, getClassType, getColumnDescriptors, getConstraintName, getConstraintText, getDependableFinder, getDescriptorName, getDescriptorType, getKeyColumns, getObjectID, getObjectName, getReferenceCount, getReferencedColumns, getSchemaDescriptor, getTableDescriptor, getTableId, getUUID, initiallyDeferred, isReferenced, isValid, makeInvalid, prepareToInvalidate, setDeferrable, setEnforced, setInitiallyDeferredMethods inherited from class TupleDescriptor
getColumnDependableFinder, getDataDictionary, getDependableFinder, isPersistent, setDataDictionaryMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Dependable
isPersistent
-
Field Details
-
referencedConstraintDescriptor
ReferencedKeyConstraintDescriptor referencedConstraintDescriptorinterface to this descriptor- public ReferencedKeyConstraintDescriptor getReferencedConstraint() throws StandardException;
- public UUID getReferencedConstraintId() throws StandardException;
- public boolean isSelfReferencingFK() throws StandardException;
-
referencedConstraintId
UUID referencedConstraintId -
raDeleteRule
int raDeleteRule -
raUpdateRule
int raUpdateRule
-
-
Constructor Details
-
ForeignKeyConstraintDescriptor
protected ForeignKeyConstraintDescriptor(DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] fkColumns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, ReferencedKeyConstraintDescriptor referencedConstraintDescriptor, boolean enforced, int raDeleteRule, int raUpdateRule) Constructor for a ForeignKeyConstraintDescriptor- Parameters:
dataDictionary- The data dictionary that this descriptor lives intable- The descriptor of the table the constraint is onconstraintName- The name of the constraint.deferrable- If the constraint can be deferred.initiallyDeferred- If the constraint starts life deferred.fkColumns- columns in the foreign keyconstraintId- UUID of constraintindexId- The UUID for the backing indexschemaDesc- The SchemaDescriptor for the constraintreferencedConstraintDescriptor- is referenced constraint descriptorenforced- is the constraint enforced?raDeleteRule- TheON DELETEaction ruleraUpdateRule- TheON UPDATEaction rule
-
ForeignKeyConstraintDescriptor
ForeignKeyConstraintDescriptor(DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] fkColumns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, UUID referencedConstraintId, boolean enforced, int raDeleteRule, int raUpdateRule) Constructor for a ForeignKeyConstraintDescriptor- Parameters:
dataDictionary- The data dictionary that this descriptor lives intable- The descriptor of the table the constraint is onconstraintName- The name of the constraint.deferrable- If the constraint can be deferred.initiallyDeferred- If the constraint starts life deferred.fkColumns- columns in the foreign keyconstraintId- UUID of constraintindexId- The UUID for the backing indexschemaDesc- The SchemaDescriptor for the constraintreferencedConstraintId- is referenced constraint idenforced-trueif this constraint is enforcedraDeleteRule- TheON DELETEaction ruleraUpdateRule- TheON UPDATEaction rule
-
-
Method Details
-
getReferencedConstraint
Get the constraint that this FK references. Will return either a primary key or a unique key constraint.- Returns:
- the constraint
- Throws:
StandardException- on error
-
getReferencedConstraintId
Get the constraint id for the constraint that this FK references. Will return either a primary key or a unique key constriant.- Returns:
- the constraint id
- Throws:
StandardException- on error
-
getConstraintType
public int getConstraintType()Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).- Specified by:
getConstraintTypein classConstraintDescriptor- Returns:
- An identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).
-
needsToFire
public boolean needsToFire(int stmtType, int[] modifiedCols) Does this constraint need to fire on this type of DML? True if insert or update and columns intersect- Specified by:
needsToFirein classConstraintDescriptor- Parameters:
stmtType- the type of DML (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)modifiedCols- the columns modified, or null for all- Returns:
- true/false
-
isSelfReferencingFK
Am I a self-referencing FK? True if my referenced constraint is on the same table as me.- Returns:
- true/false
- Throws:
StandardException- on error
-
getRaDeleteRule
public int getRaDeleteRule()Gets a referential action rule on a DELETE- Returns:
- referential rule defined by the user during foreign key creattion for a delete (like CASCDE , RESTRICT ..etc)
-
getRaUpdateRule
public int getRaUpdateRule()Gets a referential action rule on a UPDATE- Returns:
- referential rule defined by the user during foreign key creattion for an UPDATE (like CASCDE , RESTRICT ..etc)
-