users@glassfish.java.net

Re: Foreign key not being created in child entity

From: <glassfish_at_javadesktop.org>
Date: Sun, 16 Nov 2008 13:46:26 PST

I just had this problem, and didn't think the "answer" posted here was very clear. In my case, the issue was simply that, alhough my "payee" object was in the "payees" list, I had failed to assign my Clamant object to the "clamaint" variable. In other words, although I did

Claimant c = new Claimant();
Payee p = new Payee();
c.getPayees().add(p);

I forgot to do
p.setClamaint(c);

Once I added this last line it worked great, and it makes perfect sense now. But, it was a little misleading to solve since I'd have expected a foreign key failure or something like that based upon my settings, but instead it just inserted the payee with CLAIMANT_ID set to 0 (using OpenJPA 1.0.3). Weird.
[Message sent by forum member 'baileyby' (baileyby)]

http://forums.java.net/jive/thread.jspa?messageID=317005