-->
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: Best Practice When Adding 2 "Many" Elements
PostPosted: Fri May 06, 2005 4:24 pm 
Newbie

Joined: Thu May 05, 2005 5:49 pm
Posts: 11
Location: San Diego, California
Hibernate 3.0
Oracle 9i

I have a one to many relationship between ClassA (one) and ClassB (many). ClassA is already persisted in the database, but I need to insert 2 or more ClassB elements.

I have setup the relationship between ClassA and ClassB using a Map because we'll need to access the ClassB elements by their PK. However, the PK is the only unique attribute in ClassB.

The PK for ClassB is generated from an Oracle sequence which means that at the time they are created and added to ClassA's map, they both have a PK of 0 (zero).

So the Map ends up having only 1 entry in it (since both ClassB elements have the same key) and therefore only 1 row gets inserted into my table.

What is the best way to solve this problem?

Thanks in advance.

A


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.