Package org.hibernate.dialect.unique
Class DefaultUniqueDelegate
- java.lang.Object
-
- org.hibernate.dialect.unique.DefaultUniqueDelegate
-
- All Implemented Interfaces:
UniqueDelegate
- Direct Known Subclasses:
DB2UniqueDelegate,InformixUniqueDelegate,MySQLUniqueDelegate
public class DefaultUniqueDelegate extends java.lang.Object implements UniqueDelegate
The default UniqueDelegate implementation for most dialects. Uses separate create/alter statements to apply uniqueness to a column.
-
-
Constructor Summary
Constructors Constructor Description DefaultUniqueDelegate(Dialect dialect)Constructs DefaultUniqueDelegate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)Get the SQL ALTER TABLE command to be used to create the given UniqueKey.java.lang.StringgetAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)Get the SQL ALTER TABLE command to be used to drop the given UniqueKey.java.lang.StringgetColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context)Get the fragment that can be used to make a column unique as part of its column definition.protected java.lang.StringgetDropUnique()java.lang.StringgetTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)Get the fragment that can be used to apply unique constraints as part of table creation.protected java.lang.StringuniqueConstraintSql(UniqueKey uniqueKey)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.dialect.unique.UniqueDelegate
getAlterTableToAddUniqueKeyCommand, getAlterTableToDropUniqueKeyCommand, getColumnDefinitionUniquenessFragment, getTableCreationUniqueConstraintsFragment
-
-
-
-
Field Detail
-
dialect
protected final Dialect dialect
-
-
Constructor Detail
-
DefaultUniqueDelegate
public DefaultUniqueDelegate(Dialect dialect)
Constructs DefaultUniqueDelegate- Parameters:
dialect- The dialect for which we are handling unique constraints
-
-
Method Detail
-
getColumnDefinitionUniquenessFragment
public java.lang.String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context)
Description copied from interface:UniqueDelegateGet 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- Specified by:
getColumnDefinitionUniquenessFragmentin interfaceUniqueDelegate- 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
public java.lang.String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context)
Description copied from interface:UniqueDelegateGet the fragment that can be used to apply unique constraints as part of table creation. The implementation should iterate over theUniqueKeyinstances 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.- Specified by:
getTableCreationUniqueConstraintsFragmentin interfaceUniqueDelegate- 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
public java.lang.String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Description copied from interface:UniqueDelegateGet the SQL ALTER TABLE command to be used to create the given UniqueKey.- Specified by:
getAlterTableToAddUniqueKeyCommandin interfaceUniqueDelegate- 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
-
uniqueConstraintSql
protected java.lang.String uniqueConstraintSql(UniqueKey uniqueKey)
-
getAlterTableToDropUniqueKeyCommand
public java.lang.String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)
Description copied from interface:UniqueDelegateGet the SQL ALTER TABLE command to be used to drop the given UniqueKey.- Specified by:
getAlterTableToDropUniqueKeyCommandin interfaceUniqueDelegate- 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
-
getDropUnique
protected java.lang.String getDropUnique()
-
-