Hi,
I found the solution.
My Derby DB had CHAR(32) as PK. I changed it to VARCHAR(32) and it works.
Now the question is: where is the bug? In Hibernate or Derby. To test that I create the same table in MSSQL with VARCHAR -> No problem it works
I change it the VARCHAR to CHAR(32) (N.B. the key with a lenght less the 32 will be padded by spaces) and if failed.
I put it back to VARCHAR, notice that the PK will still have padded spaces. It failed again.
I repopulate the DB with a new set of data, means without spaces at the end of the PK and it works.
I have the feeling that the problem is in Hibernate because whatever is the DB Derby/MSSQL (I didn't test it with other DB, up to you) when PK has spaces at the end, something happen and it doesn't work anymore.
FYI here are my Hibernate Mappings:
Code:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping default-cascade="none">
<class name="com.xxx.Entity" table="Entity">
<id name="code" column="code">
<generator class="com.xxx.IdentifierGenerator"/>
</id>
<set name="entityMappings" lazy="false" cascade="all-delete-orphan">
<key column="entity_code"/>
<one-to-many class="com.xxx.EntityMapping"/>
</set>
</class>
</hibernate-mapping>
<hibernate-mapping default-cascade="none">
<class name="com.xxx.EntityMapping" table="EntityMapping">
<id name="code" column="code">
<generator class="com.xxx.IdentifierGenerator"/>
</id>
<property name="targetTable" column="targetTable" not-null="true"/>
</class>
</hibernate-mapping>
The IdentifierGenerator is based on net.sf.hibernate.id.UUIDHexGenerator.
I'm using Hibernate 2.1.7.
Cheers
Dominique