Hi Stephen,

there should be no need to reload the cached entities.

Regards
Ralf


Stephen Ince schrieb:
> Ralf,
>   Thx for your reply and help.  I got it to work by using 60 ttl.
> 
>         <cache-type type="time-limited" capacity="60"/>.
>          db.begin();
>         
> db.load(UserScenario.class,u.getUserScenarioId(),AccessMode.ReadOnly);
>          System.err.println("updating("+u+")=" + u.jdoGetTimeStamp());
>          db.update(u);
>          db.commit();
> 
> 
> 
> Is it necessary for me to reload the object in the cache?
>          db.begin();
>          System.err.println("updating("+u+")=" + u.jdoGetTimeStamp());
>          db.update(u);
>          db.commit();
> 
> 
> Steve
> ----- Original Message ----- From: "Ralf Joachim" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, September 30, 2008 12:32 PM
> Subject: Re: [castor-dev] ObjectModifiedException error
> 
> 
>> Hi Stephen,
>>
>> till 1.3 release of Castor there are 2 requirements for entities that
>> are used at long transactions.
>>
>> - the entity have to implement the TimeStampable interface
>> - the entity has to stay in cache from being loaded until update is
>> called with it
>>
>> According to your test scenarios the second seams not to be the case
>> (case 2).
>>
>> Backgroud of the ObjectModifiedException in cases 1 and 3 is, that an
>> entity always gets a new timestamp value when it is loaded from
>> database. As the entity you explicitly loaded into cache in cases 1 and
>> 3 got a different timestamp the ObjectModifiedException gets thrown at
>> update.
>>
>> To prevent this you have to use cache type 'unlimited' or 'time-limited'
>> with a ttl that is bigger than the time between you initial load and the
>> call to update. Having said that this also does not help if the entity
>> is part of an extends hierarchy. There is a open issue (castor-1217)
>> about that.
>>
>> If keeping entities in cache for such a long time is not an option to
>> you, maybe according to the number of entities involved, or the entity
>> is part of an extends hierarchy, there are only 2 options.
>>
>> - copy changed properties of the entity by hand into an entity loaded in
>> the transaction
>> - switch to the upcoming 1.3 release which allows to persist the
>> timestamp in database
>>
>> If you like to know more about persisting timestamp let me know and I'll
>> point you into the  right direction. To reduced turnaround you may want
>> to connect to castor channel at: http://irc.codehaus.org/
>>
>> Regards
>> Ralf
>>
>>
>> Stephen Ince schrieb:
>>> I am getting a "org.exolab.castor.jdo.ObjectModifiedException:
>>> Timestamp mismatched!" error when saving a long transactions. How can
>>> I avoid this. I have tried the following.
>>>
>>> case 1:
>>>          db.begin();
>>>
>>> db.load(UserScenario.class,u.getUserScenarioId(),AccessMode.ReadOnly));
>>>          db.update(u);
>>>          db.commit();
>>>
>>> case 2:
>>>          db.begin();
>>>          db.update(u);
>>>          db.commit();
>>>          I get object not in cache error for this case.
>>>
>>> case 3:
>>>         db.begin();
>>>
>>> db.load(UserScenario.class,u.getUserScenarioId(),AccessMode.ReadOnly));
>>>          db.commit();
>>>
>>>          db.begin();
>>>          db.update(u);
>>>          db.commit();
>>>
>>> Steve
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>
>> -- 
>>
>> Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
>> Ralf Joachim
>> Raiffeisenstraße 11
>> 72127 Kusterdingen
>> Germany
>>
>> Tel.   +49 7071 3690 52
>> Mobil: +49 173 9630135
>> Fax    +49 7071 3690 98
>>
>> Internet: www.syscon.eu
>> E-Mail: [EMAIL PROTECTED]
>>
>> Sitz der Gesellschaft: D-72127 Kusterdingen
>> Registereintrag: Amtsgericht Stuttgart, HRB 382295
>> Geschäftsleitung: Jens Joachim, Ralf Joachim
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to