-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Collection inside a VO
PostPosted: Thu Jun 12, 2008 10:05 pm 
Newbie

Joined: Thu Jun 12, 2008 9:52 pm
Posts: 11
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.