Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2
Suppose i've this schema (reduced for clear read):
create table `articles` (art_id INTEGER prymary key, art_data date)
create table `registrations` (art_id INTEGER, reg_id integer, reg_value NUMERIC, PRIMARY KEY(art_id, reg_id))
how can i map the primary key of the register?
I do:
Code:
On article:
<list name="registrazioni" table="registrations" cascade="all-delete-orphan" inverse="false">
<key column name="art_id"/>
<index column="reg_id"/>
<one-to-many class="sic.business.Registrazione"/>
</list>
on registration:
<composite-id class="sic.business.Registrazione$Id" >
<key-many-to-one name="article" class="sic.business.Articolo" column name="art_id">
<key-property name="id" type="int" column="reg_id"/>
</composite-id>
but when i call session.persist(article)
i receive a exception that the registration have same id of anothewr registration i suppose because the "id" property is null and the hashCode of Registrazione.Id is the same.
in which way i can do this mapping? i had to add another field to registrations table?