views:

246

answers:

1

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  A: 

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'.

Bryan Pendleton
Looks like a known derby issue, but the SQL was generated by Hibernate 3.3.x hbm2ddl tool. Not sure if there is a workaround for this tool to avoid creating unique for the primary key fields
Joshua
The above bug makes, derby unusable with Hibernate 3.3.x does that mean nobody is using this as a development platform? Appreciate any pointers or workarounds to resolve this issue.
Joshua
Have you tried asking the Hibernate community for advice? I understand that there is something called the 'Derby dialect for Hibernate'; perhaps you can adjust that so that Hibernate doesn't generate this SQL in this case.
Bryan Pendleton
I did use org.hibernate.dialect.DerbyDialect for hbm2ddl generation. This above issue kind of makes the latest version of Apache Derby unusable with Hibernate 3.3.x. I will ask this question also in the hibernate forum.
Joshua
Joshua, please let us know what you find out from the Hibernate community. In the meantime, there has been some progress made on DERBY-789, so if you are able to incorporate experimental Derby patches into your development environment, it'd be interesting to get some feedback about whether the patch is moving in the right direction.
Bryan Pendleton
We are not in a position to try out experimental changes right now and I haven't heard anything yet from the hibernate community on this issue.
Joshua