Issue Type: Bug Bug
Affects Versions: 4.1.8
Assignee: Unassigned
Components: core
Created: 14/Nov/12 10:52 PM
Description:

Unique constraints are not getting created with org.hibernate.tool.hbm2ddl.SchemaUpdate. This bug was introduced in HHH-7577.

Derby doesn't allow unique constraints on nullable fields.

Simple entity:

@Entity
public class SimpleEntity { @Id private Long id; @Column(unique = true, nullable = false) private String name; /* getters, setters */ }

Unique constraint isn't applied to name.

See org.hibernate.mapping.Table sqlAlterStrings and sqlCreateStrings, and org.hibernate.metamodel.relational.Table sqlCreateStrings

boolean useUniqueConstraint = col.isUnique() && ( col.isNullable() || dialect.supportsNotNullUnique() );

should be

boolean useUniqueConstraint = col.isUnique() && ( !col.isNullable() || dialect.supportsNullUnique() );

Shouldn't the method be supportsNullUnique, not supportsNotNullUnique?

Environment: Hibernate 4.1.8.Final, Apache Derby 10.9.1.0 embedded. Auto-create schema used.
Project: Hibernate ORM
Labels: dialect metamodel
Priority: Major Major
Reporter: Luke Carroll
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira