I knew there'd be work involved ... :-)
Perhaps if I can get that working, it'll clean up some other bits of my
code. I built my own caching/batching system to bulk fetch unrelated
(at least by normal query standards) groups of objects using
QueryUtils.selectQueryForIds(List) to speed up the initial fetches of
the top-level objects (again, a long story). If I can just make faults
out of them, and get batch faulting to work, then it would clean up some
of my code and then I'd have something I could maybe contribute back to
Cayenne.
I'll need to go bury my head in the Cayenne code/docs for a while now
...
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 - 11:38:28 EDT