Hi,
I've got a legacy database to deal with, and I'm almost getting crazy trying to make it work with Hibernate.
Let's say that there are 'n' Bs for each S, in a 1->n relationship.
In B, the FK (defined by tnumso field is also part of a composite-id PK.
Table S's PK mapping is like this:
<class
name="com.previsora.data.hibernate.S"
table="tatitul"
dynamic-update="false"
>
<id
name="numSolicitud"
column="tnumso"
type="long"
length="9"
unsaved-value="any"
>
<generator class="assigned">
</generator>
</id>
<set name="beneficiarios" >
<key>
<column name="tnumso"/>
</key>
<one-to-many class="com.previsora.data.hibernate.B"/>
</set>
[...]
My guess to table B mapping is:
<class
name="com.previsora.data.hibernate.B"
table="tabenef"
dynamic-update="false"
>
<composite-id name="PKBeneficiario" class="com.previsora.data.hibernate.BeneficiarioPK" unsaved-value="any">
<key-many-to-one name="numSolicitud" column="tnumso" inverse="true" />
<key-property name="numAsegurado" type="int" column="bnumer"/>
</composite-id>
But this will not work. "MappingException: No persister for long" All right, I think it means numSolicitud (which is a long indeed) but... what can I do? I've also tried:
<composite-id unsaved-value="any">
<key-property name="numSolicitud" type="long" column="tnumso"/>
<key-property name="numAsegurado" type="int" column="bnumer"/>
</composite-id>
But this does not make the many-to-one part of the relationship, and I need it.
Can anybody help me? BTW, I'm using Hibernate2.03, with mysql.
Lots of thanks,
_
Jorge
|