Werner,

I put on my dba hat and thought it was a good idea that all db.load()
operations specify Database.ReadOnly.  When I needed to change/delete an
object that was loaded ReadOnly, I would invoke db.update() prior to
operation. I assumed that castor would cache only one of the objects if
queried ReadOnly, regardless of the number of load requests.?

I have since changed a few methods around and am now allowing Castor to
load objects based on their declaration in the mapping file
(class="shared") or Castor default if not specified. I assume now that
castor will cache one for each load request.?

A solution for delete (well one that works) to the
ObjectNotFoundException is two fold, remove the item from the parent
array and update() the parent. Case:

UserTransaction 1:
ut.begin();
Database db = jdo.getDatabase();
Parent parent = db.load(Parent.class, parentKeyValue);
ut.commit();

// obtain an arbitrary child element for testing
Child child = parent.getChildArray().get(1);

UserTransaction 2:
ut.begin();
Database db = jdo.getDatabase();
db.update(child);
db.delete(child);
// custom method to remove child from parent array
parent.removeChild(child);
db.update(parent);
ut.commit();



On Tue, 2004-07-20 at 16:15, Werner Guttmann wrote:
> Donnie,
> 
> this is going to be hard to analyse as there's plenty of systems involved. Anyhow, 
> before starting to dig randomly, can you please elaborate as to why 
> you are using Database.ReadOnly when loading the parent object.
> 
> Werner
> 
> On Tue, 20 Jul 2004 11:41:14 -0500, Donnie Armstrong wrote:
> 
> >
> >oops, my case has a typo, it is supposed to be db.remove(child). Sorry.
> >
> >Also, tran2 cannot see newly created child records. Another case:
> >
> >UserTransaction 1:
> >db = jdo.getDatabase();
> >ut.begin();
> >parentObj = db.load(parent.class, parentKeyValue, Database.ReadOnly);
> >db.create(child);
> >ut.commit();
> >
> >UserTransaction 2:
> >db = jdo.getDatabase();
> >ut.begin();
> >parentObj = db.load(parent.class, parentKeyValue, Database.ReadOnly);
> >ut.commit();
> >
> >User transaction 2 does not fail, but If I obtain an iterator over the
> >array of children, I notice that my newly created child is not there.
> >
> >
> >On Tue, 2004-07-20 at 10:45, Donnie Armstrong wrote:
> >> hello,
> >> 
> >> Using Castor CVS, Global demarcation, Oracle and JBoss 3.2.3. The JDO
> >> handle is static, each transaction gets their own database handle.
> >> 
> >> UserTransaction 1:
> >> db = jdo.getDatabase()
> >> ut.begin();
> >> // Load parent which automatically loads the Array of children.
> >> parentObj = db.load(parent.class, parentKeyValue, Database.ReadOnly); 
> >> db.update(child); // to sync the timestamps
> >> db.delete(child); // remove a child
> >> ut.commit();
> >> 
> >> UserTransaction 2:
> >> db = jdo.getDatabase()
> >> ut.begin();
> >> // Load parent which automatically loads the Array of children.
> >> parentObj = db.load(parent.class, parentKeyValue, Database.ReadOnly); 
> >> 
> >> Castor throws an ObjectNotFoundException ... was not found in persistent
> >> storage.
> >> 
> >> I suspect that Castor retains the deleted object in it's cache, but why
> >> does the latter operation in transaction 2 try to load the recently
> >> deleted object from DB?
> >> 
> >> The only way I've been able to recover is to shutdown container, which
> >> resets Castor cache.
> >> 
> >> Any help would be appreciated.
> >> Donnie
> >> 
> >> 
> >> 
> >> ----------------------------------------------------------- 
> >> If you wish to unsubscribe from this mailing, send mail to
> >> [EMAIL PROTECTED] with a subject of:
> >>         unsubscribe castor-user
> >> 
> >
> >
> >
> >----------------------------------------------------------- 
> >If you wish to unsubscribe from this mailing, send mail to
> >[EMAIL PROTECTED] with a subject of:
> >        unsubscribe castor-user
> >
> 
> 
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
> 



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

Reply via email to