Package org.h2.constraint
Class Constraint
java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.constraint.Constraint
- All Implemented Interfaces:
Comparable<Constraint>,HasSQL
- Direct Known Subclasses:
ConstraintCheck,ConstraintDomain,ConstraintReferential,ConstraintUnique
The base class for constraint checking.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USERFields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS -
Method Summary
Modifier and TypeMethodDescriptionabstract voidcheckExistingData(SessionLocal session) Check the existing data.abstract voidcheckRow(SessionLocal session, Table t, Row oldRow, Row newRow) Check if this row fulfils the constraint.intcompareTo(Constraint other) abstract Constraint.TypeThe constraint type nameabstract StringGet the SQL statement to create this constraint.Returns the CHECK expression or null.getIndex()Get the index of this constraint in the source table, or null if no index is used.getReferencedColumns(Table table) Get all referenced columns.Returns the referenced unique constraint, or null.getTable()intgetType()Get the object type.abstract booleanisBefore()Check if this constraint needs to be checked before updating the data.booleanisEverything(ExpressionVisitor visitor) Visit all elements in the constraint.abstract voidrebuild()This method is called after a related table has changed (the table was renamed, or columns have been renamed).abstract voidsetIndexOwner(Index index) This index is now the owner of the specified index.abstract booleanCheck if this constraint needs the specified index.Methods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQLMethods inherited from class org.h2.engine.DbObject
checkRename, getChildren, getComment, getCreateSQL, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, invalidate, isTemporary, isValid, removeChildrenAndResources, rename, setComment, setModified, setObjectName, setTemporary, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Field Details
-
table
The table for which this constraint is defined.
-
-
Method Details
-
getConstraintType
The constraint type name- Returns:
- the name
-
checkRow
Check if this row fulfils the constraint. This method throws an exception if not.- Parameters:
session- the sessiont- the tableoldRow- the old rownewRow- the new row
-
usesIndex
Check if this constraint needs the specified index.- Parameters:
index- the index- Returns:
- true if the index is used
-
setIndexOwner
This index is now the owner of the specified index.- Parameters:
index- the index
-
getReferencedColumns
Get all referenced columns.- Parameters:
table- the table- Returns:
- the set of referenced columns
-
getExpression
Returns the CHECK expression or null.- Returns:
- the CHECK expression or null.
-
getCreateSQLWithoutIndexes
Get the SQL statement to create this constraint.- Returns:
- the SQL statement
-
isBefore
public abstract boolean isBefore()Check if this constraint needs to be checked before updating the data.- Returns:
- true if it must be checked before updating
-
checkExistingData
Check the existing data. This method is called if the constraint is added after data has been inserted into the table.- Parameters:
session- the session
-
rebuild
public abstract void rebuild()This method is called after a related table has changed (the table was renamed, or columns have been renamed). -
getIndex
Get the index of this constraint in the source table, or null if no index is used.- Returns:
- the index
-
getReferencedConstraint
Returns the referenced unique constraint, or null.- Returns:
- the referenced unique constraint, or null
-
getType
public int getType()Description copied from class:DbObjectGet the object type. -
getTable
-
getRefTable
-
compareTo
- Specified by:
compareToin interfaceComparable<Constraint>
-
isEverything
Visit all elements in the constraint.- Parameters:
visitor- the visitor- Returns:
- true if every visited expression returned true, or if there are no expressions
-