Package org.hibernate.dialect.unique
Interface UniqueDelegate
-
- All Known Implementing Classes:
DB2UniqueDelegate
,DefaultUniqueDelegate
,InformixUniqueDelegate
,MySQLUniqueDelegate
public interface UniqueDelegate
Dialect-level delegate in charge of applying "uniqueness" to a column. Uniqueness can be defined in 1 of 3 ways:-
Add a unique constraint via separate alter table statements. See
getAlterTableToAddUniqueKeyCommand(org.hibernate.mapping.UniqueKey, org.hibernate.boot.Metadata)
. Also, seegetAlterTableToDropUniqueKeyCommand(org.hibernate.mapping.UniqueKey, org.hibernate.boot.Metadata)
-
Add a unique constraint via dialect-specific syntax in table create statement. See
getTableCreationUniqueConstraintsFragment(org.hibernate.mapping.Table)
-
Add "unique" syntax to the column itself. See
getColumnDefinitionUniquenessFragment(org.hibernate.mapping.Column)
-
-
Method Summary
All Methods Instance Methods Default Methods Deprecated Methods Modifier and Type Method Description default java.lang.String
getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Deprecated.default java.lang.String
getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.default java.lang.String
getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Deprecated.default java.lang.String
getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.default java.lang.String
getColumnDefinitionUniquenessFragment(Column column)
Deprecated.ImplementgetColumnDefinitionUniquenessFragment(Column, SqlStringGenerationContext)
instead.default java.lang.String
getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context)
Get the fragment that can be used to make a column unique as part of its column definition.default java.lang.String
getTableCreationUniqueConstraintsFragment(Table table)
Deprecated.ImplementgetTableCreationUniqueConstraintsFragment(Table, SqlStringGenerationContext)
instead.default java.lang.String
getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)
Get the fragment that can be used to apply unique constraints as part of table creation.
-
-
-
Method Detail
-
getColumnDefinitionUniquenessFragment
@Deprecated default java.lang.String getColumnDefinitionUniquenessFragment(Column column)
Deprecated.ImplementgetColumnDefinitionUniquenessFragment(Column, SqlStringGenerationContext)
instead.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
- The column to which to apply the unique- Returns:
- The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach
-
getColumnDefinitionUniquenessFragment
default java.lang.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
- The column to which to apply the uniquecontext
- A context for SQL string generation- Returns:
- The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach
-
getTableCreationUniqueConstraintsFragment
@Deprecated default java.lang.String getTableCreationUniqueConstraintsFragment(Table table)
Deprecated.ImplementgetTableCreationUniqueConstraintsFragment(Table, SqlStringGenerationContext)
instead.Get the fragment that can be used to apply unique constraints as part of table creation. The implementation should iterate over theUniqueKey
instances for the given table (seeTable.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
- The table for which to generate the unique constraints fragment- Returns:
- The fragment, typically in the form
", unique(col1, col2), unique( col20)"
. NOTE: The leading comma is important!
-
getTableCreationUniqueConstraintsFragment
default java.lang.String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)
Get the fragment that can be used to apply unique constraints as part of table creation. The implementation should iterate over theUniqueKey
instances for the given table (seeTable.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
- The table for which to generate the unique constraints fragmentcontext
- A context for SQL string generation- Returns:
- The fragment, typically in the form
", unique(col1, col2), unique( col20)"
. NOTE: The leading comma is important!
-
getAlterTableToAddUniqueKeyCommand
@Deprecated default java.lang.String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Deprecated.Get the SQL ALTER TABLE command to be used to create the given UniqueKey.- Parameters:
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping information- Returns:
- The ALTER TABLE command
-
getAlterTableToAddUniqueKeyCommand
default java.lang.String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Get the SQL ALTER TABLE command to be used to create the given UniqueKey.- Parameters:
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping informationcontext
- A context for SQL string generation- Returns:
- The ALTER TABLE command
-
getAlterTableToDropUniqueKeyCommand
@Deprecated default java.lang.String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata)
Deprecated.Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.- Parameters:
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping information- Returns:
- The ALTER TABLE command
-
getAlterTableToDropUniqueKeyCommand
default java.lang.String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.- Parameters:
uniqueKey
- The UniqueKey instance. Contains all information about the columnsmetadata
- Access to the bootstrap mapping informationcontext
- A context for SQL string generation- Returns:
- The ALTER TABLE command
-
-