Top Description Inners Fields Constructors Methods
org.hibernate.mapping

public abstract Class Constraint

extends Object
implements RelationalModel, Exportable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.hibernate.boot.model.relational.Exportable, org.hibernate.mapping.RelationalModel
Known Direct Subclasses
org.hibernate.mapping.ForeignKey, org.hibernate.mapping.PrimaryKey, org.hibernate.mapping.UniqueKey
Imports
java.io.Serializable, java.math.BigInteger, java.security.MessageDigest, .NoSuchAlgorithmException, java.util.ArrayList, .Arrays, .Comparator, .Iterator, .List, .Locale, org.hibernate.HibernateException, org.hibernate.boot.model.relational.Exportable, .SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.Mapping, org.hibernate.internal.util.StringHelper

Deprecated

as a consequence of RelationalModel being deprecated. See corresponding docs for further information.

A relational constraint.
Authors
Gavin King, Brett Meyer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ArrayList<Column>
private String
private Table
table

Deprecated as a consequence of Table being deprecated.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addColumn(Column column)

public void
addColumns(Iterator<E> columnIterator)

public Iterator<Column>
columnIterator()

Deprecated (Since 6.0) use getColumnIterator() instead.
This is a duplicate method, that has been removed in v.6.0.
public boolean

Returns:

true if this constraint already contains a column with same name.
containsColumn
(Column column)

public abstract String

Returns:

String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".
generatedConstraintNamePrefix
()

public static String

Returns:

String The generated name
generateName
(String prefix, Table table, Column... columns)

Deprecated as a consequence of Table being deprecated.
If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names.
public static String

Returns:

String The generated name
generateName
(String prefix, Table table, List<Column> columns)

Deprecated as a consequence of Table being deprecated.
Helper method for generateName(String, Table, Column...).
public Column
getColumn(int i)

public Iterator<Column>
public List<Column>
public int
public String
public Table
getTable()

Deprecated as a consequence of Table being deprecated.
public static String

Returns:

String The hashed name.
hashedName
(String
The name to be hashed.
s
)

Hash a constraint name using MD5.

public boolean
public void
public void
setTable(Table table)

Deprecated as a consequence of Table being deprecated.
public abstract String
sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)

public String
public String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

columnsback to summary
private final ArrayList<Column> columns
nameback to summary
private String name
tableback to summary
private Table table

Deprecated

as a consequence of Table being deprecated. See corresponding docs for further information.

Constructor Detail

Constraintback to summary
public Constraint()

Method Detail

addColumnback to summary
public void addColumn(Column column)
addColumnsback to summary
public void addColumns(Iterator<E> columnIterator)
columnIteratorback to summary
public Iterator<Column> columnIterator()

Deprecated

(Since 6.0) use getColumnIterator() instead.

This is a duplicate method, that has been removed in v.6.0. getColumnIterator() is the one that will stay.

Annotations
@Deprecated
containsColumnback to summary
public boolean containsColumn(Column column)
Returns:boolean

true if this constraint already contains a column with same name.

generatedConstraintNamePrefixback to summary
public abstract String generatedConstraintNamePrefix()
Returns:String

String The prefix to use in generated constraint names. Examples: "UK_", "FK_", and "PK_".

generateNameback to summary
public static String generateName(String prefix, Table table, Column... columns)

Deprecated

as a consequence of Table being deprecated. See corresponding docs for further information.

If a constraint is not explicitly named, this is called to generate a unique hash using the table and column names. Static so the name can be generated prior to creating the Constraint. They're cached, keyed by name, in multiple locations.

Returns:String

String The generated name

generateNameback to summary
public static String generateName(String prefix, Table table, List<Column> columns)

Deprecated

as a consequence of Table being deprecated. See corresponding docs for further information.

Helper method for generateName(String, Table, Column...).

Returns:String

String The generated name

getColumnback to summary
public Column getColumn(int i)
getColumnIteratorback to summary
public Iterator<Column> getColumnIterator()
getColumnsback to summary
public List<Column> getColumns()
getColumnSpanback to summary
public int getColumnSpan()
getNameback to summary
public String getName()
getTableback to summary
public Table getTable()

Deprecated

as a consequence of Table being deprecated. See corresponding docs for further information.

hashedNameback to summary
public static String hashedName(String s)

Hash a constraint name using MD5. Convert the MD5 digest to base 35 (full alphanumeric), guaranteeing that the length of the name will always be smaller than the 30 character identifier restriction enforced by a few dialects.

Parameters
s:String

The name to be hashed.

Returns:String

String The hashed name.

isGeneratedback to summary
public boolean isGenerated(Dialect dialect)
setNameback to summary
public void setName(String name)
setTableback to summary
public void setTable(Table table)

Deprecated

as a consequence of Table being deprecated. See corresponding docs for further information.

sqlConstraintStringback to summary
public abstract String sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)
sqlCreateStringback to summary
public String sqlCreateString(Mapping p, SqlStringGenerationContext context, String defaultCatalog, String defaultSchema)

Implements org.hibernate.mapping.RelationalModel.sqlCreateString.

Annotations
@Override
sqlDropStringback to summary
public String sqlDropString(SqlStringGenerationContext context, String defaultCatalog, String defaultSchema)

Implements org.hibernate.mapping.RelationalModel.sqlDropString.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

org.hibernate.mapping back to summary

private Class Constraint.ColumnComparator

extends Object
implements Comparator<Column>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Field Summary

Modifier and TypeField and Description
public static Constraint.ColumnComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(Column
the first object to be compared.
col1
,
Column
the second object to be compared.
col2
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static Constraint.ColumnComparator INSTANCE

Constructor Detail

ColumnComparatorback to summary
private ColumnComparator()

Method Detail

compareback to summary
public int compare(Column col1, Column col2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
col1:Column

the first object to be compared.

col2:Column

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.