OK, I hope this isn't a silly question.
To do my initial caching, I maintain a list of unfetched ObjectIds which
I batch fetch in using QueryUtils.selectQueryForIds(List). If I get
this custom batch faulting handler working, it would make more sense (I
think) to convert my caching mechanism over to using the custom batch
faulting handler.
What's the best way to create faults (or hollow objects) on my own?
Would it be sufficient to create instances of the class, set the state
to hollow, and then set the ObjectId (which I'm already creating)? Then
the custom batch faulter could resolve those, too.
Thanks,
/dev/mrg
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: Tuesday, October 19, 2004 10:53 AM
To: cayenne-use..bjectstyle.org
Subject: Re: Batching faults?
While Cayenne does not support this out of the box, it should be
possible
to implement a custom batch fault handler. You may actually extend
org.objectstyle.cayenne.Fault, but this is not realy a requirement for a
custom implementation (though it will be required if we are to integrate
it to Cayenne core at a later time)... The idea is the following:
1. in your DataObject override "readProperty" or a specific relationship
getter method, and if a relationship target is "Fault" (or even a HOLLOW
object) use your custom Fault handler to resolve the whole batch of
related objects.
2. Now how to find objects to batch fault... Custom Fault subclass
should
implement "resolveFault(DataObject sourceObject,String
relationshipName)"
to do something like this:
- obtain an ObjectStore from a source object
- scan through the registered DataObjects in the ObjectStore that are
of
the same type as source object and that still use faults (or hollow
objects) for the resulting target relationship (obtained via
"readPropertyDirectly").
- collect a batch of such ObjectIds of desired size...
- resolve them all at once
Andrus
> "Gentry, Michael" <michael_gentr..anniemae.com> wrote:
>> Does anyone know of a way to tell Cayenne to batch faults into a
>> larger SELECT?
>>
>> I have a higher level object that has many to-one relationships off
of
>> it. I can fetch the higher level objects in pretty efficiently at
>> this point, but when I'm presenting the information in a table (web,
>> not DB), all of the single SELECTs for the faults are slowing things
>> down.
>>
>> Basically, I'm looking for a way to Cayenne that when it is time to
>> resolve a Foo ObjEntity fault, to go ahead and do 25 or 50 or 100 of
>> them instead of just one.
>>
>> Thanks!
>>
>> /dev/mrg
>>
>> PS. I can't use a prefetch in this case because I don't have a
>> SelectQuery which brings in the initial top-level objects (long
>> story).
>
> If the objects aren't related somehow in a query, I can't see what you
> could do to resolve an arbitrary set of them.
> Probably your only hope would be to submit a new query to the database
> that does refetch them.
>
> -Mike
This archive was generated by hypermail 2.0.0 : Tue Oct 19 2004 - 16:59:09 EDT