Hi I have the same problem.
I have one table with one key compounded of two foreign keys and one date and here is the result :
Code:
<class name="TchgtService" table="TCHGT_SERVICE">
<composite-id name="comp_id" class="TchgtServicePK">
<key-property name="numService" column="NUM_SERVICE" type="java.lang.Integer"/>
<key-property name="cleSalarie" column="CLE_SALARIE" type="java.lang.Integer"/>
<key-property name="dateChgtServ" column="DATE_CHGT_SERV" type="java.util.Date"/>
</composite-id>
<many-to-one name="tservice" class="Tservice" not-null="true">
<column name="NUM_SERVICE" />
</many-to-one>
<many-to-one name="tsalarie" class="Tsalarie" not-null="true">
<column name="CLE_SALARIE" />
</many-to-one>
</class>
Here the generation is ok but I have one question : why is the composite-id made of 'key-property' and why not use 'key-many-ot-one'. Is it a limitation of the tool or an hibernate 'best-practice' ?
Secondly, I have another class where the primary key is compounded just of two foreign keys. With this class, middlegen does not generate the compound key.
Code:
<class name="AbsenceJour" table="TABSENCE_JOUR">
<property name="valeurCptJour" type="java.lang.Integer" column="VALEUR_CPT_JOUR" length "10"/>
<property name="valeurCptHeure" type="java.lang.Integer" column="VALEUR_CPT_HEURE" length="10"/>
<property name="nbFiche" type="java.lang.Short" column="NB_FICHE" length="5"/>
<many-to-one name="cumulJour" class="CumulJour" not-null="true">
<column name="NUM_CUMUL" />
</many-to-one>
<many-to-one name="motifAb" class="MotifAb" not-null="true">
<column name="NUM_MOTIF" />
</many-to-one>
</class>
(In the database the primary key is compounded of 'NUM_CUMUL' and 'NUM_MOTIF')
Seb
Code: