Top Description Constructors Methods
org.hibernate.dialect.unique

public Class SkipNullableUniqueDelegate

extends CreateTableUniqueDelegate
Class Inheritance
Imports
org.hibernate.boot.Metadata, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.mapping.Column, .UniqueKey

A UniqueDelegate that only creates unique constraints on not-null columns, and ignores requests for uniqueness for nullable columns.

Needed because unique constraints on nullable columns in Sybase always consider null values to be non-unique. There is simply no way to create a unique constraint with the semantics we want on a nullable column in Sybase.

You might argue that this behavior is bad because if the programmer explicitly specifies an @UniqueKey, then we should damn well respect their wishes. But the simple answer is that the user should have also specified @Column(nullable=false) if that is what they wanted. A unique key on a nullable column just really doesn't make sense in Sybase, except, perhaps, in some incredibly corner cases.

Author
Gavin King

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
public String
getAlterTableToAddUniqueKeyCommand(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Deprecated as a consequence of Metadata being deprecated.
Get the alter table command used to create the given unique key constraint, or return the empty string if the constraint was already included in the create table statement by getTableCreationUniqueConstraintsFragment.
public String
getAlterTableToDropUniqueKeyCommand(UniqueKey
The UniqueKey instance. Contains all information about the columns
uniqueKey
,
Metadata
Access to the bootstrap mapping information
metadata
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Deprecated as a consequence of Metadata being deprecated.
Get the alter table command used to drop the given unique key which was previously created by getAlterTableToAddUniqueKeyCommand.
public String
getColumnDefinitionUniquenessFragment(Column
The column to which to apply the unique
column
,
SqlStringGenerationContext
A context for SQL string generation
context
)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getColumnDefinitionUniquenessFragment.

Implements org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Get the SQL fragment used to make the given column unique as part of its column definition, usually just " unique", or return an empty string if uniqueness does not belong in the column definition.
Inherited from org.hibernate.dialect.unique.CreateTableUniqueDelegate:
getTableCreationUniqueConstraintsFragment

Constructor Detail

SkipNullableUniqueDelegateback to summary
public SkipNullableUniqueDelegate(Dialect dialect)

Method Detail

appendUniqueConstraintback to summary
protected void appendUniqueConstraint(StringBuilder fragment, UniqueKey uniqueKey)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.appendUniqueConstraint.

Annotations
@Override
getAlterTableToAddUniqueKeyCommandback to summary
public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToAddUniqueKeyCommand.

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Get the alter table command used to create the given unique key constraint, or return the empty string if the constraint was already included in the create table statement by getTableCreationUniqueConstraintsFragment.

Parameters
uniqueKey:UniqueKey

The UniqueKey instance. Contains all information about the columns

metadata:Metadata

Access to the bootstrap mapping information

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The alter table command

Annotations
@Override
getAlterTableToDropUniqueKeyCommandback to summary
public String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Implements org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getAlterTableToDropUniqueKeyCommand.

Deprecated

as a consequence of Metadata being deprecated. See corresponding docs for further information.

Get the alter table command used to drop the given unique key which was previously created by getAlterTableToAddUniqueKeyCommand.

Parameters
uniqueKey:UniqueKey

The UniqueKey instance. Contains all information about the columns

metadata:Metadata

Access to the bootstrap mapping information

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The alter table command

Annotations
@Override
getColumnDefinitionUniquenessFragmentback to summary
public String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context)

Overrides org.hibernate.dialect.unique.CreateTableUniqueDelegate.getColumnDefinitionUniquenessFragment.

Implements org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Doc from org.hibernate.dialect.unique.UniqueDelegate.getColumnDefinitionUniquenessFragment.

Get the SQL fragment used to make the given column unique as part of its column definition, usually just " unique", or return an empty string if uniqueness does not belong in the column definition.

This is for handling single columns explicitly marked unique, not for dealing with unique keys.

Parameters
column:Column

The column to which to apply the unique

context:SqlStringGenerationContext

A context for SQL string generation

Returns:String

The fragment (usually "unique"), empty string indicates the uniqueness will be indicated using a different approach

Annotations
@Override