Class ReferencedKeyConstraintDescriptor
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.ReferencedKeyConstraintDescriptor
- All Implemented Interfaces:
Dependable, Dependent, Provider
A ReferencedConstraintDeescriptor is a primary key or a unique
key that is referenced by a foreign key.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate final intpublic interface to this descriptor: public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException; public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException; public boolean isReferenced(); public int getReferenceCount(); public int incrementReferenceCount(); public int decrementReferenceCount();private ConstraintDescriptorListprivate ConstraintDescriptorListprivate boolean(package private) intFields 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
ConstructorsModifierConstructorDescriptionprotectedReferencedKeyConstraintDescriptor(int constraintType, DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] columns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, boolean enforced, int referenceCount) Constructor for a KeyConstraintDescriptorImpl -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckType(int type) intDecrement the reference count by one.final intGets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).getForeignKeyConstraints(int type) Get the referencing foreign key constraintsgetNonSelfReferencingFK(int type) Am I referenced by a FK on another table?intGet the number of enforced fks that reference this key.booleanhasSelfReferencingFK(ConstraintDescriptorList cdl, int type) Am I referenced by a FK on the same table?intBump the reference count by one.booleanIs this constraint referenced?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, getReferencedColumns, getSchemaDescriptor, getTableDescriptor, getTableId, getUUID, initiallyDeferred, 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
-
constraintType
private final int constraintTypepublic interface to this descriptor:- public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException;
- public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException;
- public boolean isReferenced();
- public int getReferenceCount();
- public int incrementReferenceCount();
- public int decrementReferenceCount();
-
referenceCount
int referenceCount -
fkEnabledConstraintList
-
fkConstraintList
-
checkedSelfReferencing
private boolean checkedSelfReferencing -
hasSelfReferencing
private boolean hasSelfReferencing
-
-
Constructor Details
-
ReferencedKeyConstraintDescriptor
protected ReferencedKeyConstraintDescriptor(int constraintType, DataDictionary dataDictionary, TableDescriptor table, String constraintName, boolean deferrable, boolean initiallyDeferred, int[] columns, UUID constraintId, UUID indexId, SchemaDescriptor schemaDesc, boolean enforced, int referenceCount) Constructor for a KeyConstraintDescriptorImpl- Parameters:
constraintType- The type of the constraintdataDictionary- 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.columns- columns involved in the constraintconstraintId- UUID of constraintindexId- The UUID for the backing indexschemaDesc- The SchemaDescriptor for the constraintenforced- is the constraint enforced?referenceCount- number of FKs (enforced only)
-
-
Method Details
-
getConstraintType
public final int getConstraintType()Description copied from class:ConstraintDescriptorGets 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).
-
hasSelfReferencingFK
public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException Am I referenced by a FK on the same table?- Parameters:
cdl- ConstraintDescriptorList for the tabletype- ConstraintDescriptor.(ENABLED|DISABLED|ALL)- Returns:
- true/false
- Throws:
StandardException- on error
-
getNonSelfReferencingFK
Am I referenced by a FK on another table? Return the list of those foreign constraints.- Parameters:
type- ConstraintDescriptor.(ENABLED|DISABLED|ALL)- Returns:
- list of constraints
- Throws:
StandardException- on error
-
getForeignKeyConstraints
Get the referencing foreign key constraints- Parameters:
type- ConstraintDescriptor.(ENABLED|DISABLED|ALL)- Returns:
- the list of constraints (ConstraintDescriptorListImpl)
- Throws:
StandardException- on error
-
isReferenced
public boolean isReferenced()Is this constraint referenced? Returns true if there are enforced fks that reference this constraint.- Overrides:
isReferencedin classConstraintDescriptor- Returns:
- false
-
getReferenceCount
public int getReferenceCount()Get the number of enforced fks that reference this key.- Overrides:
getReferenceCountin classConstraintDescriptor- Returns:
- the number of fks
-
incrementReferenceCount
public int incrementReferenceCount()Bump the reference count by one.- Returns:
- the number of fks
-
decrementReferenceCount
public int decrementReferenceCount()Decrement the reference count by one.- Returns:
- the number of fks
-
needsToFire
public boolean needsToFire(int stmtType, int[] modifiedCols) Does this constraint need to fire on this type of DML? For referenced keys, fire if referenced by a fk, and stmt is delete or bulk insert replace, or stmt is 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
-
checkType
- Throws:
StandardException
-