Hi,

Thanks for your help, it works by locking the object inside a transaction
and the
setting the referenced object, what confused me is that for a new object you
don't have to be within a transaction for the referenced object to be
created, but for an existing one this is the case.

Thank you.

Jean-Yves

2006/3/10, Armin Waibel <[EMAIL PROTECTED]>:
>
> Hi Jean-Yves,
>
> Jean-Yves Sironneau wrote:
> > Hello,
> >
> > I looked more precisely at my issue regarding foreign keys not being
> set, so
> > now i'am using official OJB 1.0.4.
> >
> > The exact issue is that when i persist a new object (that has not been
> > persisted before), the linked object is persisted and the foreign key is
> > set. But when i retrieve an object, then sets the linked object and then
> > persists the main object this time the linked object is not persisted
> and
> > the foreign key not set.
> >
> > I'am using the following code, to do the persistence, so the linked
> object
> > is set before that code :
> >
> >     Implementation impl = OJB.getInstance();
> >     TransactionExt tx = (TransactionExt) impl.newTransaction();
> >
> >     tx.begin();
> >     tx.markDirty(product);
> >     tx.commit();
> >
> > Can that be the reason ? Is the way OJB is navigating the object graph
> > different for an
> > initial store or an update ?
> >
> > If you want i can try to package up a simple test case from that.
>
> Do you retrieve the object via oql-query and is implicit locking enabled?
>
> If you first lock the object and then set the linked object:
> >     Implementation impl = OJB.getInstance();
> >     TransactionExt tx = (TransactionExt) impl.newTransaction();
> >
> >     tx.begin();
> >     tx.lock(obj, WRITE);
> obj.setLinked(objB);
> >     tx.commit();
> >
>
> This way your test should pass.
>
> regards,
> Armin
>
> >
> >
> > Thank you for your help.
> >
> > Jean-Yves
> >
> > 2006/2/20, Jean-Yves Sironneau <[EMAIL PROTECTED]>:
> >> Hello, I have a few unrelated questions regarding OJB :
> >>
> >> - Is there a way to set the deferrable foreign key constraint setting
> >> using OJB xdoclet module ?
> >>
> >> - When i use anonymous foreign key in a relationship, it's working
> >> perfectly for collections, but
> >> for simple reference to an object, i have to store the referenced
> object
> >> and then store the object referencing
> >> it, otherwise the two objects are created in db but the foreign key id
> is
> >> not set.
> >>
> >> It's pretty hard to discover it because, when i retrieve the objects
> they
> >> are ok even if the db foreign key is not set. It's
> >> just later, if i restart my application for example, that the
> referenced
> >> objects fields are null.
> >>
> >> So i have two questions : Do you think it's normal behaviour ? And how
> can
> >> i force OJB to retrieve everything
> >> from database to be able to test this kind of possible issues ?
> >>
> >> By the way i'am using CVS version of OJB 1.1 approximately 2-3 months
> ago
> >> and the ODMG API
> >> (which is really working fine except for that).
> >>
> >> - Is the code for OJB 1.1 located in the 1.0 SVN branch ? Because i
> don't
> >> know if i better use
> >> OJB 1.0.4 (or future 1.0.5)  or the version i got from CVS.
> >>
> >>
> >> Thanks your for your help.
> >>
> >> Jean-Yves
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to