Top Description Fields Constructors Methods
org.hibernate.mapping

public abstract Class Constraint

extends Object
implements Exportable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.hibernate.boot.model.relational.Exportable
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, .List, org.hibernate.HibernateException, .MappingException, org.hibernate.boot.model.relational.Exportable, .SqlStringGenerationContext, org.hibernate.dialect.Dialect

A mapping model object representing a constraint on a relational database table.
Authors
Gavin King, Brett Meyer

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

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

public void
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)

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)

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

public Column
getColumn(int i)

public List<Column>
public int
public String
public Table
public static String

Returns:

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

Hash a constraint name using MD5.

public boolean
public void
public void
setTable(Table table)

public abstract String
sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)

Deprecated for removal since 6.2. this method is no longer called
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

Constructor Detail

Constraintback to summary
public Constraint()

Method Detail

addColumnback to summary
public void addColumn(Column column)
addColumnsback to summary
public void addColumns(Value value)
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)

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)

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

Returns:String

String The generated name

getColumnback to summary
public Column getColumn(int i)
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()
hashedNameback to summary
public static String hashedName(String name)

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
name: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)
sqlConstraintStringback to summary
public abstract String sqlConstraintString(SqlStringGenerationContext context, String constraintName, String defaultCatalog, String defaultSchema)

Deprecated

for removal since 6.2.

this method is no longer called

Annotations
@Deprecated
since:6.2
forRemoval:true
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.