You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Esteve Boix <eb...@esteveb.com> on 2007/09/13 19:44:18 UTC

OneToMany relationship creating more database entries

Hi all,

I've been experiencing a problem with OpenJPA.

Finally, I've been able to reproduce this outside my program, in an
isolated test.
You can download the test from:

http://www.esteveb.com/OpenJPATest.zip

(the mailing-list server keeps rejecting this mail as spam if I attach the file).
 
This is an small description of what is this doing:

Test1 method:
    Create a new parent object
    Store it in a map
    Persist it

Test2 method:
    Retrieve parent from map
    Add 2 childs
    Update it to database

Test3 method:
    Retrieve parent from map
    Add 2 childs more
    Update it to database

After Test3, I end up with a child table with 6 childs. 2 from the first
run (Test2), and 4 from the second run (Test3).

Debugging the program with Netbeans, I see that OpenJPA doesn't update
the id of the childs when I persist de parent, thus in the next run,
it thinks that the childs are new (that's my guess).

I'm using OpenJPA 1.0.0 on Java6, and Derby.

Regards,
Esteve