Donnie,
thanks for coming back to the list with your resolution. I am glad to see that
everything is fine you.
Werner
WOn Thu, 22 Jul 2004 17:47:38 -0500, Donnie Armstrong wrote:
>
>Solved.
>
>I tracked the problem to our developers issuing "db.delete(child)"
>without updating the array in the parent nor updating the parent. So
>when they issued "db.load(Parent.class, ParentKeyValue)" they were
>getting the ObjectNotFoundException. Our fixed case:
>
>Parent parent = (Parent) db.load(Parent.class, parentKeyValue);
>parent.getChildArr().remove(child);
>db.update(parent);
>
>To make things interesting for them, I added dependent relationships on
>the child back to the parent. That way the developers will not take
>matters into their own hands and load/delete children directly, but
>instead get a ClassNotPersistenceCapableException. Case:
>
>Child db.load(Child.class, childKeyValue);
>
>Now we are on our way (for now). Thanks Werner!
>
>Donnie
>
>On Wed, 2004-07-21 at 04:56, Werner Guttmann wrote:
>> Donnie,
>>
>> please see inline ...
>>
>> Werner
>>
>> > Werner,
>> >
>> > I put on my dba hat and thought it was a good idea that all db.load()
>> > operations specify Database.ReadOnly.
>> No, it unfortunately isn't. Objects should be loaded as readonly only if you
>> do not plan to modify them during the course of your current transaction.
>> There's some documentation on this, so please consider revisiting this.
>>
>> > When I needed to change/delete an
>> > object that was loaded ReadOnly, I would invoke db.update() prior to
>> > operation.
>> Which, afair, would not work, as objects loaded readonly are (internally)
>> treated differently than the ones loaded e.g. in sahred mode.
>>
>> > I assumed that castor would cache only one of the objects if
>> > queried ReadOnly, regardless of the number of load requests.?
>> Castor will ALWAYS cache one instance only, irrespective of the access mode.
>> >
>> > 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.?
>> No, if Castor has successfully loaded an object instance for which caching
>> is enabled, is will cache this one instance only. Why would it want to cache
>> one instance mnore than once ?
>>
>> > 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.
>> It could well be that I have missed something here, but is this problem
>> again related to readonly access, or completely unrelated ?
>>
>> >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
>> >
>>
>>
>>
>> -----------------------------------------------------------
>> 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