Interface UniqueDelegate
- All Known Implementing Classes:
DelegatingUniqueDelegate
Applies logical unique declarations to database DDL.
A delegate owns all three possible emission points: a single-column
definition, the create table constraint list, and separate add/drop
commands. It also selects whether metadata and DDL represent a logical
declaration as a constraint or a unique index. Keep those decisions
coherent by consulting representation(UniqueKeyRepresentationRequest) instead of a separate Dialect
capability.
Implement this contract for provider-specific behavior, decorate a stock
strategy with DelegatingUniqueDelegate, or obtain a standard strategy
from UniqueDelegates. Return empty fragments or commands when the selected
emission point does not apply. Do not retain the mutable mapping arguments.
Hibernate requires null values in nullable unique declarations to be distinct. A delegate for a database with different native semantics must use a suitable index, suppress an unsupported nullable declaration, or otherwise preserve that behavior.
- Since:
- 8.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) Render the complete command which adds the unique key.getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) Render the complete command which drops the unique key previously emitted bygetAlterTableToAddUniqueKeyCommand(UniqueKey, Metadata, SqlStringGenerationContext).getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context) Render the column-definition uniqueness fragment for a column explicitly marked [Column#isUnique() unique].getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context) Render all unique declarations embedded increate table.default UniqueKeyRepresentationSelect whether a logical unique declaration is represented as a constraint or an index.default booleanWhether this delegate can rendernulls not distinctfor a requested unique constraint.
-
Method Details
-
representation
Select whether a logical unique declaration is represented as a constraint or an index. -
supportsNullsNotDistinct
default boolean supportsNullsNotDistinct()Whether this delegate can rendernulls not distinctfor a requested unique constraint. -
getColumnDefinitionUniquenessFragment
Render the column-definition uniqueness fragment for a column explicitly marked [Column#isUnique() unique]. Return an empty string when uniqueness belongs at another emission point. -
getTableCreationUniqueConstraintsFragment
Render all unique declarations embedded increate table. Include the required leading comma, or return an empty string when no declaration is emitted at this point. -
getAlterTableToAddUniqueKeyCommand
String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) Render the complete command which adds the unique key. Return an empty string when it was already emitted during table creation or is unsupported. -
getAlterTableToDropUniqueKeyCommand
String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) Render the complete command which drops the unique key previously emitted bygetAlterTableToAddUniqueKeyCommand(UniqueKey, Metadata, SqlStringGenerationContext). Return an empty string when no corresponding database object was created.
-