Top Description Fields Constructors Methods
org.h2.constraint

public Class ConstraintUnique

extends Constraint
Class Inheritance
Imports
java.util.ArrayList, .HashSet, org.h2.engine.SessionLocal, .NullsDistinct, org.h2.index.Index, org.h2.result.Row, org.h2.schema.Schema, org.h2.table.Column, .IndexColumn, .Table, org.h2.util.StringUtils

A unique constraint. This object always backed by a unique index.

Field Summary

Modifier and TypeField and Description
private IndexColumn[]
private Index
private boolean
private NullsDistinct
private final boolean
Inherited from org.h2.constraint.Constraint:
table

Constructor Summary

AccessConstructor and Description
public
ConstraintUnique(Schema schema, int id, String name, Table table, boolean primaryKey, NullsDistinct nullsDistinct)

Method Summary

Modifier and TypeMethod and Description
public void
checkExistingData(SessionLocal
the session
session
)

Implements abstract org.h2.constraint.Constraint.checkExistingData.

Check the existing data.

public void
checkRow(SessionLocal
the session
session
,
Table
the table
t
,
Row
the old row
oldRow
,
Row
the new row
newRow
)

Implements abstract org.h2.constraint.Constraint.checkRow.

Check if this row fulfils the constraint.

public IndexColumn[]
public Constraint.Type
getConstraintType()

Implements abstract org.h2.constraint.Constraint.getConstraintType.

The constraint type name

public String
getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ...

public String
getCreateSQLForCopy(Table
the new table
forTable
,
String
the quoted name
quotedName
)

Overrides org.h2.engine.DbObject.getCreateSQLForCopy.

Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

private String
getCreateSQLForCopy(Table forTable, String quotedName, boolean internalIndex)

public String
getCreateSQLWithoutIndexes()

Implements abstract org.h2.constraint.Constraint.getCreateSQLWithoutIndexes.

Get the SQL statement to create this constraint.

public Index
getIndex()

Overrides org.h2.constraint.Constraint.getIndex.

Get the index of this constraint in the source table, or null if no index is used.

public NullsDistinct

Returns:

are nulls distinct
getNullsDistinct
()

public HashSet<Column>
getReferencedColumns(Table
the table
table
)

Implements abstract org.h2.constraint.Constraint.getReferencedColumns.

Get all referenced columns.

public boolean
isBefore()

Implements abstract org.h2.constraint.Constraint.isBefore.

Check if this constraint needs to be checked before updating the data.

public void
rebuild()

Implements abstract org.h2.constraint.Constraint.rebuild.

This method is called after a related table has changed (the table was renamed, or columns have been renamed).

public void
removeChildrenAndResources(SessionLocal
the session
session
)

Implements abstract org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

public void
public void
setIndex(Index
the index
index
,
boolean
true if the index is generated by the system and belongs to this constraint
isOwner
)

Set the index to use for this unique constraint.

public void
setIndexOwner(Index
the index
index
)

Implements abstract org.h2.constraint.Constraint.setIndexOwner.

This index is now the owner of the specified index.

public boolean
usesIndex(Index
the index
idx
)

Implements abstract org.h2.constraint.Constraint.usesIndex.

Check if this constraint needs the specified index.

Inherited from org.h2.constraint.Constraint:
compareTogetExpressiongetReferencedConstraintgetRefTablegetTablegetTypeisEverything

Field Detail

columnsback to summary
private IndexColumn[] columns
indexback to summary
private Index index
indexOwnerback to summary
private boolean indexOwner
nullsDistinctback to summary
private NullsDistinct nullsDistinct
primaryKeyback to summary
private final boolean primaryKey

Constructor Detail

ConstraintUniqueback to summary
public ConstraintUnique(Schema schema, int id, String name, Table table, boolean primaryKey, NullsDistinct nullsDistinct)

Method Detail

checkExistingDataback to summary
public void checkExistingData(SessionLocal session)

Implements abstract org.h2.constraint.Constraint.checkExistingData.

Doc from org.h2.constraint.Constraint.checkExistingData.

Check the existing data. This method is called if the constraint is added after data has been inserted into the table.

Parameters
session:SessionLocal

the session

Annotations
@Override
checkRowback to summary
public void checkRow(SessionLocal session, Table t, Row oldRow, Row newRow)

Implements abstract org.h2.constraint.Constraint.checkRow.

Doc from org.h2.constraint.Constraint.checkRow.

Check if this row fulfils the constraint. This method throws an exception if not.

Parameters
session:SessionLocal

the session

t:Table

the table

oldRow:Row

the old row

newRow:Row

the new row

Annotations
@Override
getColumnsback to summary
public IndexColumn[] getColumns()
getConstraintTypeback to summary
public Constraint.Type getConstraintType()

Implements abstract org.h2.constraint.Constraint.getConstraintType.

Doc from org.h2.constraint.Constraint.getConstraintType.

The constraint type name

Returns:Constraint.Type

the name

Annotations
@Override
getCreateSQLback to summary
public String getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Doc from org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getCreateSQLForCopyback to summary
public String getCreateSQLForCopy(Table forTable, String quotedName)

Overrides org.h2.engine.DbObject.getCreateSQLForCopy.

Doc from org.h2.engine.DbObject.getCreateSQLForCopy.

Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

Parameters
forTable:Table

the new table

quotedName:String

the quoted name

Returns:String

the SQL statement

Annotations
@Override
getCreateSQLForCopyback to summary
private String getCreateSQLForCopy(Table forTable, String quotedName, boolean internalIndex)
getCreateSQLWithoutIndexesback to summary
public String getCreateSQLWithoutIndexes()

Implements abstract org.h2.constraint.Constraint.getCreateSQLWithoutIndexes.

Doc from org.h2.constraint.Constraint.getCreateSQLWithoutIndexes.

Get the SQL statement to create this constraint.

Returns:String

the SQL statement

Annotations
@Override
getIndexback to summary
public Index getIndex()

Overrides org.h2.constraint.Constraint.getIndex.

Doc from org.h2.constraint.Constraint.getIndex.

Get the index of this constraint in the source table, or null if no index is used.

Returns:Index

the index

Annotations
@Override
getNullsDistinctback to summary
public NullsDistinct getNullsDistinct()
Returns:NullsDistinct

are nulls distinct

getReferencedColumnsback to summary
public HashSet<Column> getReferencedColumns(Table table)

Implements abstract org.h2.constraint.Constraint.getReferencedColumns.

Doc from org.h2.constraint.Constraint.getReferencedColumns.

Get all referenced columns.

Parameters
table:Table

the table

Returns:HashSet<Column>

the set of referenced columns

Annotations
@Override
isBeforeback to summary
public boolean isBefore()

Implements abstract org.h2.constraint.Constraint.isBefore.

Doc from org.h2.constraint.Constraint.isBefore.

Check if this constraint needs to be checked before updating the data.

Returns:boolean

true if it must be checked before updating

Annotations
@Override
rebuildback to summary
public void rebuild()

Implements abstract org.h2.constraint.Constraint.rebuild.

Doc from org.h2.constraint.Constraint.rebuild.

This method is called after a related table has changed (the table was renamed, or columns have been renamed).

Annotations
@Override
removeChildrenAndResourcesback to summary
public void removeChildrenAndResources(SessionLocal session)

Implements abstract org.h2.engine.DbObject.removeChildrenAndResources.

Doc from org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

Parameters
session:SessionLocal

the session

Annotations
@Override
setColumnsback to summary
public void setColumns(IndexColumn[] columns)
setIndexback to summary
public void setIndex(Index index, boolean isOwner)

Set the index to use for this unique constraint.

Parameters
index:Index

the index

isOwner:boolean

true if the index is generated by the system and belongs to this constraint

setIndexOwnerback to summary
public void setIndexOwner(Index index)

Implements abstract org.h2.constraint.Constraint.setIndexOwner.

Doc from org.h2.constraint.Constraint.setIndexOwner.

This index is now the owner of the specified index.

Parameters
index:Index

the index

Annotations
@Override
usesIndexback to summary
public boolean usesIndex(Index idx)

Implements abstract org.h2.constraint.Constraint.usesIndex.

Doc from org.h2.constraint.Constraint.usesIndex.

Check if this constraint needs the specified index.

Parameters
idx:Index

the index

Returns:boolean

true if the index is used

Annotations
@Override