You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Olmanson, Alan" <al...@firepond.com> on 2002/12/16 16:12:40 UTC

Referential Integrity Constraints

Hello,

For our application we are using a database that has a lot of referential
integrity constraints in it.  And we have run into a situation in which OJB
is hitting one of them.

The problems occurs when we are storing a graph of objects, using the PB.  

	A m<--1 B 1-->m C 1-->m D m<--1 A

In the database the B and C's are already existing.  We create a object A
which is has a reference to B, for each C attached to B we create a object D
which is also added to a collection on A.

The problem arises when A is stored.  First OJB marks A as being stored,
saves it references (B) which stores B's collections (C) which stores C's
collections (D) which tries to stores its references (A) A is already marked
as stored (however it isn't in the database, since we are still storing its
references). When we try to store D we get a referential integrity error
because the record referenced in A by D doesn't exist.

Is this a bug/oversight in the PB, or something we need to work around in
our DB/code?

Alan  

Re: Referential Integrity Constraints

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi alan,

thanks for your testcase.
do you think we could solve the problem by storing A _before_ storing it's
references and collections ?

jakob

----- Original Message -----
From: "Olmanson, Alan" <al...@firepond.com>
To: <oj...@jakarta.apache.org>
Sent: Monday, December 16, 2002 4:12 PM
Subject: Referential Integrity Constraints


> Hello,
>
> For our application we are using a database that has a lot of referential
> integrity constraints in it.  And we have run into a situation in which
OJB
> is hitting one of them.
>
> The problems occurs when we are storing a graph of objects, using the PB.
>
> A m<--1 B 1-->m C 1-->m D m<--1 A
>
> In the database the B and C's are already existing.  We create a object A
> which is has a reference to B, for each C attached to B we create a object
D
> which is also added to a collection on A.
>
> The problem arises when A is stored.  First OJB marks A as being stored,
> saves it references (B) which stores B's collections (C) which stores C's
> collections (D) which tries to stores its references (A) A is already
marked
> as stored (however it isn't in the database, since we are still storing
its
> references). When we try to store D we get a referential integrity error
> because the record referenced in A by D doesn't exist.
>
> Is this a bug/oversight in the PB, or something we need to work around in
> our DB/code?
>
> Alan
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>