I know that there are a lot of threads with the same question, but I tried all seggested solutions and none worked for me...
Here are part of my mapping (generated with hbm2hbmxml)
Code:
<hibernate-mapping>
<class name="OfferteFornitori" table="offerte_fornitori">
<composite-id name="id" class="OfferteFornitoriId">
<key-property name="fkFornitori" type="short">
<column name="fk_fornitori" />
</key-property>
<key-property name="fkRdo" type="int">
<column name="fk_rdo" />
</key-property>
</composite-id>
<many-to-one name="rdo" class="Rdo" update="false" insert="false" fetch="select">
<column name="fk_rdo" not-null="true" />
</many-to-one>
<many-to-one name="fornitori" class="Fornitori" update="false" insert="false" fetch="select">
<column name="fk_fornitori" not-null="true" />
</many-to-one>
<property name="codice" type="string">
<column name="codice" length="65535" />
</property>
</class>
<class name="ArticoliOfferti" table="articoli_offerti">
<composite-id name="id" class="ArticoliOffertiId">
<key-property name="fkOfferteFornitoriFor" type="short">
<column name="fk_offerte_fornitori_for" />
</key-property>
<key-property name="fkOfferteFornitoriRdo" type="int">
<column name="fk_offerte_fornitori_rdo" />
</key-property>
<key-property name="fkArticoli" type="int">
<column name="fk_articoli" />
</key-property>
</composite-id>
<many-to-one name="articoli" class="Articoli" update="false" insert="false" fetch="select">
<column name="fk_articoli" not-null="true" />
</many-to-one>
<many-to-one name="offerteFornitoriByFkOfferteFornitoriFor" class="OfferteFornitori" insert="false" update="false" fetch="select">
<column name="fk_offerte_fornitori_for" not-null="true" />
</many-to-one>
<many-to-one name="offerteFornitoriByFkOfferteFornitoriRdo" class="OfferteFornitori" update="false" insert="false" fetch="select">
<column name="fk_offerte_fornitori_rdo" not-null="true" />
</many-to-one>
<property name="prezzo" type="double">
<column name="prezzo" precision="0" scale="0" not-null="true" />
</property>
</class>
</hibernate-mapping>
Trying to generate the java code with hbm2java I got:
Code:
org.hibernate.MappingException: Foreign key (FK405FC7E1E8A9975D:articoli_offerti [fk_offerte_fornitori_for])) must have same number of columns as the referenced primary key (offerte_fornitori [fk_fornitori,fk_rdo])
I tried using property-ref, putting key-many-to-one, but nothing works...
Any suggestion?
Thank you in advance.