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?
|