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

public Class AlterTableUniqueDelegate

extends Object
implements UniqueDelegate
Class Inheritance
All Implemented Interfaces
org.hibernate.dialect.unique.UniqueDelegate
Known Direct Subclasses
org.hibernate.dialect.unique.AlterTableUniqueIndexDelegate, org.hibernate.dialect.unique.CreateTableUniqueDelegate, org.hibernate.dialect.unique.DefaultUniqueDelegate
Imports
org.hibernate.boot.Metadata, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.mapping.Column, .Table, .UniqueKey

A UniqueDelegate which uses alter table commands to create and drop the unique constraint. When possible, prefer CreateTableUniqueDelegate.
Author
Brett Meyer

Field Summary

Modifier and TypeField and Description
protected final Dialect

Constructor Summary

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

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
)

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Deprecated as a consequence of Metadata being deprecated.
Get the alter table command used to create the given unique key constraint, or return the empty string if the constraint was already included in the create table statement by getTableCreationUniqueConstraintsFragment.
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
)

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Deprecated as a consequence of Metadata being deprecated.
Get the alter table command used to drop the given unique key which was previously created by getAlterTableToAddUniqueKeyCommand.
public String
getColumnDefinitionUniquenessFragment(Column
The column to which to apply the unique
column
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Implements org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Get the SQL fragment used to make the given column unique as part of its column definition, usually just " unique", or return an empty string if uniqueness does not belong in the column definition.
public String
getTableCreationUniqueConstraintsFragment(Table
The table for which to generate the unique constraints fragment
table
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Implements org.hibernate.dialect.unique.UniqueDelegate.getTableCreationUniqueConstraintsFragment.

Get the SQL fragment used to specify the unique constraints on the given table as part of the create table command, with a leading comma, usually something like:
, unique(x,y), constraint abc unique(a,b,c)
protected String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dialectback to summary
protected final Dialect dialect

Constructor Detail

AlterTableUniqueDelegateback to summary
public AlterTableUniqueDelegate(Dialect dialect)
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)

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

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

Deprecated

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

Get the alter table command used to create the given unique key constraint, or return the empty string if the constraint was already included in the create table statement by getTableCreationUniqueConstraintsFragment.

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)

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

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

Deprecated

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

Get the alter table command used to drop the given unique key which was previously created by getAlterTableToAddUniqueKeyCommand.

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)

Implements org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

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

Get the SQL fragment used to make the given column unique as part of its column definition, usually just " unique", or return an empty string if uniqueness does not belong in the column definition.

This is for handling single columns explicitly marked unique, not for dealing with unique keys.

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
getTableCreationUniqueConstraintsFragmentback to summary
public String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)

Implements org.hibernate.dialect.unique.UniqueDelegate.getTableCreationUniqueConstraintsFragment.

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

Get the SQL fragment used to specify the unique constraints on the given table as part of the create table command, with a leading comma, usually something like:

, unique(x,y), constraint abc unique(a,b,c)

or return an empty string if there are no unique constraints or if the unique constraints do not belong in the table definition.

The implementation should iterate over the unique keys of the given table by calling org.hibernate.mapping.Table#getUniqueKeys() and generate a fragment which includes all the unique key declarations.

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)". The leading comma is important!

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