Re: Re: Circular references issue

"Bruno CROS" <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hello,

I guess you have to do the 2 steps in the same way with PB API. Database
constraints needs the same sequence of insert/update.

If using  PB API, i don't think you're dealing with rollback ability, if
not, write the 2 steps as it were 2 standalone PB processes and it should
work.

Else, find out how to flush with PB API (post queries without commit).

Regards



On 6 Dec 2006 18:15:07 -0000, Virgo Smart <[email protected]> wrote:
>
>
> Hello,
>
> Is there a way to do the same using Persistence Broker APIs ?
>
> Thanks and Regards,
> Gautam.
>
>
> On Wed, 06 Dec 2006 Bruno CROS wrote :
> >The circular references have to be build in 2 steps :
> >
> >First, create instances and link one relation.
> >Flush (write SQL insert and update)
> >Second, link with the second relation (in back side).
> >Commit.
> >
> >Your example :
> >
> >tx.begin();
> >d = new Drawer();
> >f = new Finish();
> >tx.lock(d);
> >tx.lock(f);
> >d.setFinish(f);
> >((ExtTransaction) tx).flush() // post INSERT queries
> >f.setDrawer(d);
> >tx.commit();
> >
> >If you have to delete one object, you have to break the circular
> reference
> >in the same way.
> >
> >tx.lock(d);
> >d.setFinish(null);
> >ExtTx.flush(); // post UPDATE set FINISHPK=null
> >Impl.getDatabase().deletePersistent(f);
> >tx.commit();
> >
> >Don't change java class definition (circular references relations), write
> >your processes as you should do with JDBC only.
> >
> >Bruno.
> >
> >On 12/6/06, Armin Waibel <[email protected]> wrote:
> >>
> >>Hello,
> >>
> >>I have a scenario in which there are two classes which reference each
> >>other. Eg. class Drawer references Finish and Finish references Drawer.
> >>When I attempt to persist Drawer instance, an exception is thrown
> >>suggesting that we cannot add or update a child row: a foreign key
> >>reference fails.
> >>
> >>Is there a way to correct this problem without changing the Java class
> >>definitions ?
> >>
> >>Thanks and Regards,
> >>Gautam.
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [email protected]
> >>For additional commands, e-mail: [email protected]
> >>
> >>
>
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.