Top Description Fields Constructors Methods
org.apache.derby.iapi.sql.dictionary

public Class ReferencedKeyConstraintDescriptor

extends KeyConstraintDescriptor
Class Inheritance
Imports
org.apache.derby.catalog.UUID, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.StatementType

A ReferencedConstraintDeescriptor is a primary key or a unique key that is referenced by a foreign key.

Field Summary

Modifier and TypeField and Description
private boolean
private final int
constraintType

public interface to this descriptor:

  1. public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException;
  2. public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException;
  3. public boolean isReferenced();
  4. public int getReferenceCount();
  5. public int incrementReferenceCount();
  6. public int decrementReferenceCount();
private ConstraintDescriptorList
private ConstraintDescriptorList
private boolean
pack-priv int
Inherited from org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor:
indexId

Constructor Summary

AccessConstructor and Description
protected
ReferencedKeyConstraintDescriptor(int
The type of the constraint
constraintType
,
DataDictionary
The data dictionary that this descriptor lives in
dataDictionary
,
TableDescriptor
The descriptor of the table the constraint is on
table
,
String
The name of the constraint.
constraintName
,
boolean
If the constraint can be deferred.
deferrable
,
boolean
If the constraint starts life deferred.
initiallyDeferred
,
int[]
columns involved in the constraint
columns
,
UUID
UUID of constraint
constraintId
,
UUID
The UUID for the backing index
indexId
,
SchemaDescriptor
The SchemaDescriptor for the constraint
schemaDesc
,
boolean
is the constraint enforced?
enforced
,
int
number of FKs (enforced only)
referenceCount
)

Constructor for a KeyConstraintDescriptorImpl

Method Summary

Modifier and TypeMethod and Description
private void
checkType(int type)

public int

Returns:

the number of fks
decrementReferenceCount
()

Decrement the reference count by one.

public final int
getConstraintType()

Implements abstract org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.getConstraintType.

Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).

public ConstraintDescriptorList

Returns:

the list of constraints (ConstraintDescriptorListImpl)
getForeignKeyConstraints
(int
ConstraintDescriptor.(ENABLED|DISABLED|ALL)
type
)

Get the referencing foreign key constraints

public ConstraintDescriptorList

Returns:

list of constraints
getNonSelfReferencingFK
(int
ConstraintDescriptor.(ENABLED|DISABLED|ALL)
type
)

Am I referenced by a FK on another table?

public int

Returns:

the number of fks
getReferenceCount
()

Overrides org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.getReferenceCount.

Get the number of enforced fks that reference this key.

public boolean

Returns:

true/false
hasSelfReferencingFK
(ConstraintDescriptorList
ConstraintDescriptorList for the table
cdl
,
int
ConstraintDescriptor.(ENABLED|DISABLED|ALL)
type
)

Am I referenced by a FK on the same table?

public int

Returns:

the number of fks
incrementReferenceCount
()

Bump the reference count by one.

public boolean

Returns:

false
isReferenced
()

Overrides org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.isReferenced.

Is this constraint referenced?

public boolean

Returns:

true/false
needsToFire
(int
the type of DML (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)
stmtType
,
int[]
the columns modified, or null for all
modifiedCols
)

Implements abstract org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.needsToFire.

Does this constraint need to fire on this type of DML?

Inherited from org.apache.derby.iapi.sql.dictionary.KeyConstraintDescriptor:
getConglomerateIdgetIndexConglomerateDescriptorgetIndexIdgetIndexUUIDStringhasBackingIndextoString

Field Detail

checkedSelfReferencingback to summary
private boolean checkedSelfReferencing
constraintTypeback to summary
private final int constraintType

public interface to this descriptor:

  1. public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException;
  2. public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException;
  3. public boolean isReferenced();
  4. public int getReferenceCount();
  5. public int incrementReferenceCount();
  6. public int decrementReferenceCount();
fkConstraintListback to summary
private ConstraintDescriptorList fkConstraintList
fkEnabledConstraintListback to summary
private ConstraintDescriptorList fkEnabledConstraintList
hasSelfReferencingback to summary
private boolean hasSelfReferencing
referenceCountback to summary
pack-priv int referenceCount

Constructor Detail

ReferencedKeyConstraintDescriptorback to summary
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:int

The type of the constraint

dataDictionary:DataDictionary

The data dictionary that this descriptor lives in

table:TableDescriptor

The descriptor of the table the constraint is on

constraintName:String

The name of the constraint.

deferrable:boolean

If the constraint can be deferred.

initiallyDeferred:boolean

If the constraint starts life deferred.

columns:int[]

columns involved in the constraint

constraintId:UUID

UUID of constraint

indexId:UUID

The UUID for the backing index

schemaDesc:SchemaDescriptor

The SchemaDescriptor for the constraint

enforced:boolean

is the constraint enforced?

referenceCount:int

number of FKs (enforced only)

Method Detail

checkTypeback to summary
private void checkType(int type) throws StandardException
decrementReferenceCountback to summary
public int decrementReferenceCount()

Decrement the reference count by one.

Returns:int

the number of fks

getConstraintTypeback to summary
public final int getConstraintType()

Implements abstract org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.getConstraintType.

Doc from org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.getConstraintType.

Gets an identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).

Returns:int

An identifier telling what type of descriptor it is (UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK).

getForeignKeyConstraintsback to summary
public ConstraintDescriptorList getForeignKeyConstraints(int type) throws StandardException

Get the referencing foreign key constraints

Parameters
type:int

ConstraintDescriptor.(ENABLED|DISABLED|ALL)

Returns:ConstraintDescriptorList

the list of constraints (ConstraintDescriptorListImpl)

Exceptions
StandardException:
on error
getNonSelfReferencingFKback to summary
public ConstraintDescriptorList getNonSelfReferencingFK(int type) throws StandardException

Am I referenced by a FK on another table? Return the list of those foreign constraints.

Parameters
type:int

ConstraintDescriptor.(ENABLED|DISABLED|ALL)

Returns:ConstraintDescriptorList

list of constraints

Exceptions
StandardException:
on error
getReferenceCountback to summary
public int getReferenceCount()

Overrides org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.getReferenceCount.

Get the number of enforced fks that reference this key.

Returns:int

the number of fks

Annotations
@Override
hasSelfReferencingFKback to summary
public boolean hasSelfReferencingFK(ConstraintDescriptorList cdl, int type) throws StandardException

Am I referenced by a FK on the same table?

Parameters
cdl:ConstraintDescriptorList

ConstraintDescriptorList for the table

type:int

ConstraintDescriptor.(ENABLED|DISABLED|ALL)

Returns:boolean

true/false

Exceptions
StandardException:
on error
incrementReferenceCountback to summary
public int incrementReferenceCount()

Bump the reference count by one.

Returns:int

the number of fks

isReferencedback to summary
public boolean isReferenced()

Overrides org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.isReferenced.

Is this constraint referenced? Returns true if there are enforced fks that reference this constraint.

Returns:boolean

false

Annotations
@Override
needsToFireback to summary
public boolean needsToFire(int stmtType, int[] modifiedCols)

Implements abstract org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor.needsToFire.

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.

Parameters
stmtType:int

the type of DML (StatementType.INSERT|StatementType.UPDATE|StatementType.DELETE)

modifiedCols:int[]

the columns modified, or null for all

Returns:boolean

true/false