Top Description Methods
org.hibernate.dialect.unique

public Interface UniqueDelegate

Known Direct Implementers
org.hibernate.dialect.unique.DefaultUniqueDelegate
Imports
org.hibernate.boot.Metadata, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.mapping.Column, .Table, .UniqueKey

Dialect-level delegate in charge of applying "uniqueness" to a column. Uniqueness can be defined in 1 of 3 ways:
  1. Add a unique constraint via separate alter table statements. See getAlterTableToAddUniqueKeyCommand. Also, see getAlterTableToDropUniqueKeyCommand
  2. Add a unique constraint via dialect-specific syntax in table create statement. See getTableCreationUniqueConstraintsFragment
  3. Add "unique" syntax to the column itself. See getColumnDefinitionUniquenessFragment
#1 & #2 are preferred, if possible; #3 should be solely a fall-back. See HHH-7797.
Author
Brett Meyer

Method Summary

Modifier and TypeMethod and Description
public default String

Returns:

The ALTER TABLE command
getAlterTableToAddUniqueKeyCommand
(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
)

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

Returns:

The ALTER TABLE command
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
)

Deprecated as a consequence of UniqueKey being deprecated.
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.
public default String

Returns:

The ALTER TABLE command
getAlterTableToDropUniqueKeyCommand
(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
)

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

Returns:

The ALTER TABLE command
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
)

Deprecated as a consequence of UniqueKey being deprecated.
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.
public default String

Returns:

The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach
getColumnDefinitionUniquenessFragment
(Column
The column to which to apply the unique
column
)

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

Returns:

The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach
getColumnDefinitionUniquenessFragment
(Column
The column to which to apply the unique
column
,
SqlStringGenerationContext
A context for SQL string generation
context
)

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

public default String

Returns:

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

Note

The leading comma is important!

getTableCreationUniqueConstraintsFragment
(Table
The table for which to generate the unique constraints fragment
table
)

Get the fragment that can be used to apply unique constraints as part of table creation.
public default String

Returns:

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

Note

The leading comma is important!

getTableCreationUniqueConstraintsFragment
(Table
The table for which to generate the unique constraints fragment
table
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Deprecated as a consequence of Table being deprecated.
Get the fragment that can be used to apply unique constraints as part of table creation.

Method Detail

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

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

Returns:String

The ALTER TABLE command

Annotations
@Deprecated
getAlterTableToAddUniqueKeyCommandback to summary
public default String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)

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

getAlterTableToDropUniqueKeyCommandback to summary
public default String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)

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

Returns:String

The ALTER TABLE command

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

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

getColumnDefinitionUniquenessFragmentback to summary
public default String getColumnDefinitionUniquenessFragment(Column column)

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

Returns:String

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

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

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

getTableCreationUniqueConstraintsFragmentback to summary
public default String getTableCreationUniqueConstraintsFragment(Table table)

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

Returns:String

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

Note

The leading comma is important!

Annotations
@Deprecated
getTableCreationUniqueConstraintsFragmentback to summary
public default String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)

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!