使用apache derby和hbm2ddl的约束问题

Joe*_*Joe 1 hibernate jpa derby hbm2ddl

我们在Hibernate 3.3.x中使用Apache Derby 10.5.3.0_1和hbm2ddl

在嵌入式derby数据库上预加载SQL时出现以下约束错误.如果我从create table sql中删除主键(id),它就能够创建表.不知道这里有什么问题.

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.
Run Code Online (Sandbox Code Playgroud)

Bry*_*ton 5

我相信这是DERBY-789,还没有修复.基本问题是该列被声明为"唯一"和"主键",这会导致Derby尝试创建两个约束索引.由于"主键"已经暗示"独特",因此您可以省略"唯一",我认为,这比省略"主键"更好.