Quresh,

Maybe the following doc will help you:

http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/manual.html#ref_guide_mapping_jpa_fk

Cheers,
Milosz


> Hi,
>     I am getting really odd behavior on this issue. I have two objects:
>      1> Project
>      2> Employee.
>     
>     Project has a OneToMany with Employee, and the Employee maps back to 
> Project with ManyToOne. When I try to add a new Project, with new Employee 
> objects, it sometimes works and sometimes doesn't. The beauty of it, I did a 
> regression test - with a 10 hits, sometimes it would fail 3 out of 10 times, 
> other times it would be failing 8 out of 10. In my code, I do 
> entityManager.persist(project), and then I simply add my employee items to 
> the collection object on the Project. The failure message as reported from 
> Oracle:
> 
> Caused by ORA-02291: integrity constraint (PAT.FK_PROJECT_EMPL) violated - 
> parent key not found
> 
> Further more, I took the code and deployed it in Weblogic, and exposed it as 
> a WS. Two more oddities, in WebLogic (I know, I know, it uses KODO), if I 
> call it with two employee objects per Project, it succeeds - 100% of the 
> times (I called the service over 100 times not a single failure) - the moment 
> I start specifying one child per parent, it starts failing any number of 
> times. (No constant failure rate).
> I did the same thing with a TestNG test suite using OpenJPA (1.2.0) and ran 
> it just 10 times with multiple child records (2) per each parent. I couldn't 
> even get a 100% success rate on that. Fails 3-4 times (atleast) out of the 10 
> runs I do.
> 
> What gets me is - the code hasn't changed between the multiple executions - 
> whats happening here?
> 
> I am not doing an explicit persist on the child records - even though I tried 
> that to no avail.
> I tried calling the persist on the Parent BEFORE adding the child records to 
> the Parent's collection - to no success.
> I then started doing the persist on the Parent AFTER adding the child records 
> to the Parent - I knew this to be incorrect, and well - it too failed.
> 
> If anyone else has faced such issues - or knows anything about this - I would 
> appreciate it.
> 
> Thanks,
> Quresh.
> 
> 
> _________________________________________________________________
> Stay up to date on your PC, the Web, and your mobile phone with Windows Live
> http://clk.atdmt.com/MRT/go/119462413/direct/01/

Reply via email to