Hi all,
I have a Table CAR for which CAR_ID is the PK. I have another table called PARTS where CAR_ID is a foreign key to CAR. PARTS table has a composite Key of CAR_ID and PART_ID.
My requirement is to have a collection of Parts VO inside Car VO, so that when i save Car Vo, the collection of Parts VO will also be saved in PARTS table.
CAR
-------
CAR_ID | CAR_NAME
PARTS
----------
CAR_ID | PART_ID | PART_NAME
I generated the hbm file and VO using Middlegen. So I have another java class for the Composite Key in PARTS. But Middlegen did not generate the code for a collection of Parts in hbm file. How do i write this ?
The code I have written now is this ...
<class name="Car" table="CAR">
...
<set role="parts" table="PARTS">
<key column="??????????"/>
<one-to-many class="Parts"/>
</set>
</class>
The doubtful part is "<key column="??????????"/>" How do I specify the composite key here ? is this the correct way to achieve what i need ?
Thanks in advance
Vinod
|