Bernd,

please have a look at 

http://castor.exolab.org/long-transact.html#Bounded-dirty-checking

Let me quote the relevant part of this (short) description:

The advantage of the bounded dirty checking is that it doesn't require any changes to 
the database schema. It uses the Castor cache to store object 
timestamps. The disadvantage of this algorithm is that it is *bounded by a lifetime of 
the cached copy of the object*. After the cached copy has been 
purged, db.update() causes ObjectModifiedException.

In other words, if you do not define a (performance) cache for your class, you won't 
be able to use long transactions. As your mapping files does not use 
the <cache-type> element to define a cache, can I please ask you to reconsider whether 
using a cache is an option for you, and if so, to turn it on and 
see whether your problem still persists.

Regards
Werner

On Fri, 16 Jan 2004 15:33:57 +0100, Bernd Laengerich wrote:

>Hello,
>
>I am currently trying to solve a problem with castor throwing above 
>exception for an update (long transaction).
>
>The main course of events is:
>
>...
>Integer id = new Integer(24);
>db.begin();
>MyClass x = db.load(MyClass.class,id);
>db.commit();
>...
>// this works
>x.setState(UNCONFIRMED);
>db.begin();
>db.update(x);
>db.commit();
>
>// do something else
>db.begin();
>OQLQuery oql = db.getOQLQuery("SELECT o FROM my.objects.Another o 
>WHERE reference = $1");
>oql.bind(x);
>QueryResults results = oql.execute();
>int sum = 0;
>while (results.hasMore()) {
> Another y = (Another)results.next();
> sum += y.getAmount();
>}
>results.close();
>db.commit();
>
>// later
>// this does not work anymore
>x.setState(CONFIRMED);
>db.begin();
>db.update(x);
>db.commit();
>
>Mapping:
><!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 
>1.0//EN"
>                           "http://castor.exolab.org/mapping.dtd";>
><mapping>
>[...]
><class name="my.objects.BaseClass" 
> identity="id">
>
> <map-to table="BaseTable" />
>
> <field name="id" type="integer">
>  <sql name="id" type="integer" />
> </field>
></class>
>
><class name="my.objects.MyClass" 
> extends="my.objects.BaseClass" 
> identity="id">
>
> <map-to table="MyTable" />
>
> <field name="id" type="integer">
>  <sql name="id" type="integer" />
> </field>
>
></class>
>
><class name="my.objects.Another" 
> identity="id">
>
> <map-to table="AnotherTable" />
>
> <field name="id" type="integer">
>  <sql name="id" type="integer" />
> </field>
>
> <field name="reference" type="my.objects.BaseClass">
>  <sql name="invoice" />
> </field>
>
> <field name="amount" type="integer">
>  <sql name="amount" type="integer" />
> </field>
>
></class>
>
>It seems the problem is the selected objects instantiates another 
>MyObject with the same id. I can see storing the instance during 
>commit() with following DEBUG:
>Castor: Storing my.objects.BaseClass (24)
>
>but I don't know why, as the row in the data base is unchanged
>
>Any hints are appreciated.
>
>Bernd
>Mit freundlichen Gr��en
>
>Bernd Laengerich
>-- 
>act'o-soft GmbH Informationssysteme  Tel. +49-5203-974440
>Enger Stra�e 12                      Fax: +49-5203-974441
>D-33824 Werther (Westf.)             http://www.actosoft.de
>HRB 2612  GF: Christian Malachowski, Dipl.-Ing. Michael Schramm
>---------------------------------------------------------------------
>This e-mail including any attachments may contain information that is
>legally privileged and confidential. It constitutes non-public 
>information intended to be conveyed only to the designated  
>recipient(s). If you are not an intended recipient please delete this
>e-mail and any attachments and do not read, copy, or retransmit it 
>and please notify act'o-soft GmbH by return mail, e-mail or 
>at +49/5203/974440. 
>The unauthorized use, dissemination, distribution or reproduction of 
>this e-mail, including attachments, is prohibited and may be 
>unlawful.
>---------------------------------------------------------------------
>
>----------------------------------------------------------- 
>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