You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Stuart Bedoll <be...@us.ibm.com> on 2007/10/13 01:24:01 UTC

Is there a known issue with one-to-many/many-to-one object mapping ?


I am trying to store a simple parent/child object model in our Oracle DB.
With openjpa 1.0 snapshot (from july) this works 60% of the time.  The
other 40% of the time the Insert  sql for the child object is executed
before the Insert sql of the parent. Thus, the parent key not found sql
exception occurs. I moved up to openjpa 1.0 release and it now happens
every time.  I followed the example in the Users manual example 12.17 using
Company as the parent and Magazine as the child object.

Child object has this annotation:

@ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST)
@JoinColumn(name="PUB_ID")
private Company publisher;


Parent object has this annotation:

@OneToMany(mappedBy="publisher", cascade=CascadeType.PERSIST)
private Collection<Magazine> mags;

Re: Is there a known issue with one-to-many/many-to-one object mapping ?

Posted by Patrick Linskey <pl...@gmail.com>.
Hi,

It sounds like OpenJPA doesn't know about your foreign key constraints
on that relationship, and is therefore re-ordering, and sometimes that
results in inappropriate ordering.

-Patrick

On 10/12/07, Stuart Bedoll <be...@us.ibm.com> wrote:
>
>
> I am trying to store a simple parent/child object model in our Oracle DB.
> With openjpa 1.0 snapshot (from july) this works 60% of the time.  The
> other 40% of the time the Insert  sql for the child object is executed
> before the Insert sql of the parent. Thus, the parent key not found sql
> exception occurs. I moved up to openjpa 1.0 release and it now happens
> every time.  I followed the example in the Users manual example 12.17 using
> Company as the parent and Magazine as the child object.
>
> Child object has this annotation:
>
> @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST)
> @JoinColumn(name="PUB_ID")
> private Company publisher;
>
>
> Parent object has this annotation:
>
> @OneToMany(mappedBy="publisher", cascade=CascadeType.PERSIST)
> private Collection<Magazine> mags;


-- 
Patrick Linskey
202 669 5907