diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java index 4c2e96903d..be8131bf1d 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java @@ -394,7 +394,7 @@ public class Table implements RelationalModel, Serializable { boolean useUniqueConstraint = column.isUnique() && dialect.supportsUnique() && - ( !column.isNullable() || dialect.supportsNotNullUnique() ); + ( column.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { alter.append( " unique" ); } @@ -495,7 +495,7 @@ public class Table implements RelationalModel, Serializable { } boolean useUniqueConstraint = col.isUnique() && - ( !col.isNullable() || dialect.supportsNotNullUnique() ); + ( col.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { if ( dialect.supportsUnique() ) { buf.append( " unique" ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Table.java b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Table.java index 1aa57c9669..4d7562a776 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/Table.java @@ -200,7 +200,7 @@ public class Table extends AbstractTableSpecification implements Exportable { } boolean useUniqueConstraint = col.isUnique() && - ( !col.isNullable() || dialect.supportsNotNullUnique() ); + ( col.isNullable() || dialect.supportsNotNullUnique() ); if ( useUniqueConstraint ) { if ( dialect.supportsUnique() ) { buf.append( " unique" );