使用 apache derby 和 hbm2ddl 的约束问题
我们使用 Apache Derby 10.5.3.0_1 和 hbm2ddl 以及 Hibernate 3.3.x
在嵌入式 derby 数据库上预加载 SQL 时出现以下约束错误。如果我从创建表 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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这是 DERBY-789,并且尚未修复。基本问题是该列被声明为“唯一”和“主键”,这导致 Derby 尝试创建两个约束索引。由于“主键”已经意味着“唯一”,因此您可以省略“唯一”,我认为这比省略“主键”更好。
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'.