问题
We are using Apache Derby 10.5.3.0_1 and hbm2ddl with Hibernate 3.3.x
I get the following constraints error while pre-loading the SQL on an embedded derby database. If I remove the primary key(id) from the create table sql, it's able to create the table. Not sure what the problem is over here.
create table user_flow (id integer not null generated always as identity unique, creation_date timestamp not null, name varchar(255), primary key (id));
[INFO] Constraints 'SQL100219175052781' and 'SQL100219175052780' have the same set of columns, which is not allowed.
回答1:
This is DERBY-789, I believe, and has not yet been fixed. The basic issue is that the column is declared as both 'unique' and 'primary key', which causes Derby to try to create two constraint indexes. Since 'primary key' already implies 'unique', you can just omit the 'unique', which is, I think, better than omitting the 'primary key'.
来源:https://stackoverflow.com/questions/2296293/constraint-problems-using-apache-derby-and-hbm2ddl