| java.lang.Object org.hsqldb.Constraint
Constraint | class Constraint (Code) | | Implementation of a table constraint with references to the indexes used
by the constraint.
author: Thomas Mueller (Hypersonic SQL Group) version: 1.8.0 since: Hypersonic SQL |
Constructor Summary | |
| Constraint(HsqlName name, Table t, Index index, int type) | | Constraint(HsqlName name, Constraint fkconstraint) | | Constraint(HsqlName pkname, HsqlName name, Table mainTable, Table refTable, int[] mainCols, int[] refCols, Index mainIndex, Index refIndex, int deleteAction, int updateAction) Constructor for foreign key constraints. | | Constraint(HsqlName name, int[] mainCols, Table refTable, int[] refCols, int type, int deleteAction, int updateAction) |
Method Summary | |
void | checkCheckConstraint(Session session, Object[] row) | void | checkInsert(Session session, Object[] row) Checks for foreign key or check constraint violation when
inserting a row into the child table. | static void | checkReferencedRows(Session session, Table table, int[] rowColArray, Index mainIndex) Check used before creating a new foreign key cosntraint, this method
checks all rows of a table to ensure they all have a corresponding
row in the main table. | RowIterator | findFkRef(Session session, Object[] row, boolean delete) New method to find any referencing row for a
foreign key (finds row in child table). | int | getDeleteAction() | String | getFkName() | Table | getMain() | int[] | getMainColumns() | Index | getMainIndex() | HsqlName | getName() Returns the HsqlName. | String | getPkName() | Table | getRef() | int[] | getRefColumns() | Index | getRefIndex() | int | getType() | int | getUpdateAction() | boolean | hasColumn(Table table, String colname) | boolean | hasColumn(int colIndex) | boolean | hasMainRef(Session session, Object[] row) For the candidate table row, finds any referring node in the main table.
This is used to check referential integrity when updating a node. | boolean | isEquivalent(int[] col, int type) Compares this with another constraint column set. | boolean | isEquivalent(Table tablemain, int[] colmain, Table tableref, int[] colref) Compares this with another constraint column set. | boolean | isIndexFK(Index index) Returns true if an index is part this constraint and the constraint is set for
a foreign key. | boolean | isIndexUnique(Index index) Returns true if an index is part this constraint and the constraint is set for
a unique constraint. | void | replaceTable(Table oldt, Table newt, int colindex, int adjust) Used to update constrains to reflect structural changes in a table. |
CASCADESET_NULLNO_ACTIONSET_DEFAULTINIT_DEFERREDINIT_IMMEDIATENOT_DEFERRABLE | final static int CASCADESET_NULLNO_ACTIONSET_DEFAULTINIT_DEFERREDINIT_IMMEDIATENOT_DEFERRABLE(Code) | | |
FOREIGN_KEYMAINUNIQUECHECKPRIMARY_KEY | final static int FOREIGN_KEYMAINUNIQUECHECKPRIMARY_KEY(Code) | | |
constName | HsqlName constName(Code) | | |
Constraint | Constraint(HsqlName name, Table t, Index index, int type)(Code) | | Constructor declaration for PK and UNIQUE
|
Constraint | Constraint(HsqlName name, Constraint fkconstraint)(Code) | | Constructor for main constraints (foreign key references in PK table)
|
Constraint | Constraint(HsqlName pkname, HsqlName name, Table mainTable, Table refTable, int[] mainCols, int[] refCols, Index mainIndex, Index refIndex, int deleteAction, int updateAction) throws HsqlException(Code) | | Constructor for foreign key constraints.
Parameters: pkname - name in the main (referenced) table, used internally Parameters: name - name in the referencing table, public name of the constraint Parameters: mainTable - referenced table Parameters: refTable - referencing talbe Parameters: mainCols - array of column indexes in main table Parameters: refCols - array of column indexes in referencing table Parameters: mainIndex - index on the main table Parameters: refIndex - index on the referencing table Parameters: deleteAction - triggered action on delete Parameters: updateAction - triggered action on update exception: HsqlException - |
Constraint | Constraint(HsqlName name, int[] mainCols, Table refTable, int[] refCols, int type, int deleteAction, int updateAction)(Code) | | temp constraint constructor
|
checkInsert | void checkInsert(Session session, Object[] row) throws HsqlException(Code) | | Checks for foreign key or check constraint violation when
inserting a row into the child table.
|
checkReferencedRows | static void checkReferencedRows(Session session, Table table, int[] rowColArray, Index mainIndex) throws HsqlException(Code) | | Check used before creating a new foreign key cosntraint, this method
checks all rows of a table to ensure they all have a corresponding
row in the main table.
|
findFkRef | RowIterator findFkRef(Session session, Object[] row, boolean delete) throws HsqlException(Code) | | New method to find any referencing row for a
foreign key (finds row in child table). If ON DELETE CASCADE is
supported by this constraint, then the method finds the first row
among the rows of the table ordered by the index and doesn't throw.
Without ON DELETE CASCADE, the method attempts to finds any row that
exists, in which case it throws an exception. If no row is found,
null is returned.
(fredt@users)
Parameters: row - array of objects for a database row Parameters: forDelete - should we allow 'ON DELETE CASCADE' or 'ON UPDATE CASCADE' Node object or null throws: HsqlException - |
getDeleteAction | int getDeleteAction()(Code) | | The ON DELETE triggered action of (foreign key) constraint
|
getFkName | String getFkName()(Code) | | probably a misnomer, but DatabaseMetaData.getCrossReference specifies
it this way (I suppose because most FKs are declared against the PK of
another table)
name of the index for the referencing foreign key |
getMainColumns | int[] getMainColumns()(Code) | | Returns the main table column index array
|
getMainIndex | Index getMainIndex()(Code) | | Returns the main index
|
getName | HsqlName getName()(Code) | | Returns the HsqlName.
|
getPkName | String getPkName()(Code) | | probably a misnomer, but DatabaseMetaData.getCrossReference specifies
it this way (I suppose because most FKs are declared against the PK of
another table)
name of the index refereneced by a foreign key |
getRef | Table getRef()(Code) | | Returns the reference table
|
getRefColumns | int[] getRefColumns()(Code) | | Returns the reference table column index array
|
getRefIndex | Index getRefIndex()(Code) | | Returns the reference index
|
getType | int getType()(Code) | | Returns the type of constraint
|
getUpdateAction | int getUpdateAction()(Code) | | The ON UPDATE triggered action of (foreign key) constraint
|
hasColumn | boolean hasColumn(Table table, String colname)(Code) | | Only for check constraints
|
hasColumn | boolean hasColumn(int colIndex)(Code) | | |
hasMainRef | boolean hasMainRef(Session session, Object[] row) throws HsqlException(Code) | | For the candidate table row, finds any referring node in the main table.
This is used to check referential integrity when updating a node. We
have to make sure that the main table still holds a valid main record.
If a valid row is found the corresponding Node is returned.
Otherwise a 'INTEGRITY VIOLATION' Exception gets thrown.
|
isEquivalent | boolean isEquivalent(int[] col, int type)(Code) | | Compares this with another constraint column set. This implementation
only checks UNIQUE constraints.
|
isEquivalent | boolean isEquivalent(Table tablemain, int[] colmain, Table tableref, int[] colref)(Code) | | Compares this with another constraint column set. This implementation
only checks FOREIGN KEY constraints.
|
isIndexFK | boolean isIndexFK(Index index)(Code) | | Returns true if an index is part this constraint and the constraint is set for
a foreign key. Used for tests before dropping an index.
|
isIndexUnique | boolean isIndexUnique(Index index)(Code) | | Returns true if an index is part this constraint and the constraint is set for
a unique constraint. Used for tests before dropping an index.
|
replaceTable | void replaceTable(Table oldt, Table newt, int colindex, int adjust) throws HsqlException(Code) | | Used to update constrains to reflect structural changes in a table.
Prior checks must ensure that this method does not throw.
Parameters: oldt - reference to the old version of the table Parameters: newt - referenct to the new version of the table Parameters: colindex - index at which table column is added or removed Parameters: adjust - -1, 0, +1 to indicate if column is added or removed throws: HsqlException - |
|
|