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
|
|