I'm sure db.update is only intended for long-running transactions. We have
code like yours in our application
but we don't call the db.update() function. We' use the autoStore facility
although commit works just as well.

Castor will automatically persist any changes made to a an object directly,
that it is aware, ie. tagged as persistable.
We have a servlet --> session bean architecture with Castor used with the
session bean transaction space. Our
updates look like this:

1. Servlet makes change to c, e.g c.setValue1("somevalue");
2. Servlet sends changed "c" to CastorSessionBean via method call.
3. CastorSessionBean loads db-version of c into the method, let call this
version c".
* We now have two instances of c, namely c and c", in the body of the
method.
4. We now use Reflection to get a list of setMethods() on c" and call the
corresponding
getMethod() on c, ie.  c".setMethod(c.getMethod).
5. AutoStore or db.commit() take care of the persistence.

In summary I guess we've written an update() method that works for
short-running
transactions, that persist changes originally made outside a Castor-led
transaction.

Hope it helps,
Ijonas.

P.S. We've had autoStore running for ages. Certainly the 0.9.3.9 version
supports it.
----- Original Message -----
From: "Toni Charlot" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, December 23, 2001 9:20 PM
Subject: Re: [castor-dev] JDO: update() & relations


> try the cvs version.  I had same problem and Thomas fixed it a few weeks
> ago.  make sure you objects implement TimeStampable for long transaction.
> You should be able to do something like this:
>
> c.setValue1("somevalue");
> db.begin();
> db.update(c);
> db.commit();
>
> notice you're modifying c outside to the transaction then just update.
>
> good luck.
>
>
> -----Original Message-----
> From: Julian L�ffelhardt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 20, 2001 5:52 AM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] JDO: update() & relations
>
>
> Hi,
> I have the following question:
> If I have an object strucutre similar to the following:
>
> A 1--->n B 1---->n C
>
>
> db.begin();
> c.setValue1("somevalue");
> db.update(c);
> db.commit();
>
> and I want to update object C I getan error like:
> error object C contains reference to object B which is not created/loaded
in
> this transaction
>
> than I try:
>
> db.begin();
> c.setValue1("somevalue");
> db.update(c);
> db.update(b);
> db.commit();
>
> I get an error like:
> error object B contains reference to object A which is not created/loaded
in
> this transaction
>
> an do on...
>
> Problem is I#m having a rather comp�lex structure of classes forcing me to
> call update on about 12 objects when I want to change a simple value.
> Any advice???
>
> P.S: the "autostore" function seems completely broken, whenever I enab�le
> autostore Castor starts to blindly create new objects e.g.
>
> A 1--->n B 1---->n C
>
>
> db.begin();
> c.setValue1("somevalue");
> db.update(c);
> db.commit();
>
> creates "sometimes" a new instance of a and B althought it's already
> existing.
>
> Can anybody with the proper insight givr me an advise???
>
> Thanks in advance,
>
> julian L�ffelhardt
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to