Since version 4.1.8 of hibernate core it is not possible to generate any unique constraint using schema exporter. Columns marked as unique are not generated as unique any more (independent if they are nullable or not!!).
E.g. following mapping
<property name="myName" column="MYNAME" type="string" length="4096" access="field" unique="true" not-null="true" />
is now generated as
create table xxx (
...
MYNAME varchar(4096) not null,
primary key (ID)
);
In hibernate version 4.1.7 it was correctly generated as:
create table xxx (
...
MYNAME varchar(4096) not null,
primary key (ID),
unique (MYNAME)
);
Same is true if I set column to be Nullable:
<property name="myName" column="MYNAME" type="string" length="4096" access="field" unique="true" not-null="false" />
It seems that the logic regarding the combination of the two flags column.isNullable() and dialect.supportsNotNullUnique() is not consistent between the operations Table.sqlCreateString() and UniqueKey.sqlConstraintString() !!!
|