public class DefaultUniqueDelegate extends Object implements UniqueDelegate
The default UniqueDelegate implementation for most dialects. Uses separate create/alter statements to apply uniqueness to a column.
| Constructor and Description |
|---|
DefaultUniqueDelegate(Dialect dialect)
Constructs DefaultUniqueDelegate
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey,
Metadata metadata)
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.
|
String |
getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey,
Metadata metadata)
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.
|
String |
getColumnDefinitionUniquenessFragment(Column column)
Get the fragment that can be used to make a column unique as part of its column definition.
|
protected String |
getDropUnique() |
String |
getTableCreationUniqueConstraintsFragment(Table table)
Get the fragment that can be used to apply unique constraints as part of table creation.
|
protected String |
uniqueConstraintSql(UniqueKey uniqueKey) |
protected final Dialect dialect
public DefaultUniqueDelegate(Dialect dialect)
Constructs DefaultUniqueDelegate
dialect - The dialect for which we are handling unique constraintspublic String getColumnDefinitionUniquenessFragment(Column column)
UniqueDelegateGet the fragment that can be used to make a column unique as part of its column definition. <p/> This is intended for dialects which do not support unique constraints
getColumnDefinitionUniquenessFragment in interface UniqueDelegatecolumn - The column to which to apply the uniquepublic String getTableCreationUniqueConstraintsFragment(Table table)
UniqueDelegateGet the fragment that can be used to apply unique constraints as part of table creation. The implementation
should iterate over the UniqueKey instances for the given table (see
Table.getUniqueKeyIterator() and generate the whole fragment for all
unique keys
<p/>
Intended for Dialects which support unique constraint definitions, but just not in separate ALTER statements.
getTableCreationUniqueConstraintsFragment in interface UniqueDelegatetable - The table for which to generate the unique constraints fragment", unique(col1, col2), unique( col20)". NOTE: The leading
comma is important!public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
UniqueDelegateGet the SQL ALTER TABLE command to be used to create the given UniqueKey.
getAlterTableToAddUniqueKeyCommand in interface UniqueDelegateuniqueKey - The UniqueKey instance. Contains all information about the columnsmetadata - Access to the bootstrap mapping informationpublic String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
UniqueDelegateGet the SQL ALTER TABLE command to be used to drop the given UniqueKey.
getAlterTableToDropUniqueKeyCommand in interface UniqueDelegateuniqueKey - The UniqueKey instance. Contains all information about the columnsmetadata - Access to the bootstrap mapping informationprotected String getDropUnique()
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.