Top Description Fields Constructors Methods
org.hibernate.dialect.unique

public Class DefaultUniqueDelegate

extends Object
implements UniqueDelegate
Class Inheritance
All Implemented Interfaces
org.hibernate.dialect.unique.UniqueDelegate
Known Direct Subclasses
org.hibernate.dialect.unique.InformixUniqueDelegate, org.hibernate.dialect.unique.MySQLUniqueDelegate, org.hibernate.dialect.unique.DB2UniqueDelegate
Imports
java.util.Iterator, org.hibernate.boot.Metadata, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.mapping.Column, .Table, .UniqueKey

The default UniqueDelegate implementation for most dialects. Uses separate create/alter statements to apply uniqueness to a column.
Author
Brett Meyer

Field Summary

Modifier and TypeField and Description
protected final Dialect

Constructor Summary

AccessConstructor and Description
public
DefaultUniqueDelegate(Dialect
The dialect for which we are handling unique constraints
dialect
)

Constructs DefaultUniqueDelegate

Method Summary

Modifier and TypeMethod and Description
public String
getAlterTableToAddUniqueKeyCommand(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Deprecated as a consequence of UniqueKey being deprecated.
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.
public String
getAlterTableToDropUniqueKeyCommand(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Deprecated as a consequence of UniqueKey being deprecated.
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.
public String
getColumnDefinitionUniquenessFragment(Column
The column to which to apply the unique
column
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Get the fragment that can be used to make a column unique as part of its column definition.
protected String
public String
getTableCreationUniqueConstraintsFragment(Table
The table for which to generate the unique constraints fragment
table
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getTableCreationUniqueConstraintsFragment.

Deprecated as a consequence of Table being deprecated.
Get the fragment that can be used to apply unique constraints as part of table creation.
protected String
uniqueConstraintSql(UniqueKey uniqueKey)

Deprecated as a consequence of UniqueKey being deprecated.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dialectback to summary
protected final Dialect dialect

Constructor Detail

DefaultUniqueDelegateback to summary
public DefaultUniqueDelegate(Dialect dialect)

Constructs DefaultUniqueDelegate

Parameters
dialect:Dialect

The dialect for which we are handling unique constraints

Method Detail

getAlterTableToAddUniqueKeyCommandback to summary
public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Deprecated

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

Get the SQL ALTER TABLE command to be used to create the given UniqueKey.

Parameters
uniqueKey:UniqueKey

The UniqueKey instance. Contains all information about the columns

metadata:Metadata

Access to the bootstrap mapping information

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The ALTER TABLE command

Annotations
@Override
getAlterTableToDropUniqueKeyCommandback to summary
public String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Deprecated

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

Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.

Parameters
uniqueKey:UniqueKey

The UniqueKey instance. Contains all information about the columns

metadata:Metadata

Access to the bootstrap mapping information

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The ALTER TABLE command

Annotations
@Override
getColumnDefinitionUniquenessFragmentback to summary
public String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Get the fragment that can be used to make a column unique as part of its column definition.

This is intended for dialects which do not support unique constraints

Parameters
column:Column

The column to which to apply the unique

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach

Annotations
@Override
getDropUniqueback to summary
protected String getDropUnique()
getTableCreationUniqueConstraintsFragmentback to summary
public String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)

Overrides default org.hibernate.dialect.unique.UniqueDelegate.getTableCreationUniqueConstraintsFragment.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getTableCreationUniqueConstraintsFragment.

Deprecated

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

Get the fragment that can be used to apply unique constraints as part of table creation. The implementation should iterate over the org.hibernate.mapping.UniqueKey instances for the given table (see org.hibernate.mapping.Table#getUniqueKeyIterator() and generate the whole fragment for all unique keys

Intended for Dialects which support unique constraint definitions, but just not in separate ALTER statements.

Parameters
table:Table

The table for which to generate the unique constraints fragment

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The fragment, typically in the form ", unique(col1, col2), unique( col20)".

Note

The leading comma is important!

Annotations
@Override
uniqueConstraintSqlback to summary
protected String uniqueConstraintSql(UniqueKey uniqueKey)

Deprecated

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