public interface UniqueDelegate
Dialect-level delegate in charge of applying "uniqueness" to a column. Uniqueness can be defined
in 1 of 3 ways:<ol>
<li>
Add a unique constraint via separate alter table statements. See getAlterTableToAddUniqueKeyCommand(org.hibernate.mapping.UniqueKey, org.hibernate.boot.Metadata)
.
Also, see getAlterTableToDropUniqueKeyCommand(org.hibernate.mapping.UniqueKey, org.hibernate.boot.Metadata)
</li>
<li>
Add a unique constraint via dialect-specific syntax in table create statement. See
getTableCreationUniqueConstraintsFragment(org.hibernate.mapping.Table)
</li>
<li>
Add "unique" syntax to the column itself. See getColumnDefinitionUniquenessFragment(org.hibernate.mapping.Column)
</li>
</ol>
#1 & #2 are preferred, if possible; #3 should be solely a fall-back.
See HHH-7797.
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.
|
String |
getTableCreationUniqueConstraintsFragment(Table table)
Get the fragment that can be used to apply unique constraints as part of table creation.
|
String getColumnDefinitionUniquenessFragment(Column column)
Get 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
column
- The column to which to apply the uniqueString 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 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.
table
- The table for which to generate the unique constraints fragment", unique(col1, col2), unique( col20)"
. NOTE: The leading
comma is important!String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping informationString getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping informationCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.