Hmmm…but I guess there wouldn’t be another way to do it unless you knew the original query.
On Tue, Oct 4, 2016 at 8:59 AM, Lon Varscsak <lon.varsc...@gmail.com> wrote: > So, I finally got back around to this (still no solution). What you’re > describing isn’t really what I’m after. What I’d like to do is take an > object (or array of objects) and a list of keys and have Cayenne basically > do the same fetching it does with it’s pre-fetching code. > > So when I use addPrefetch to a query, by default it will execute a fetch > for each of the relationships. This allows me to decide at the application > level what keys are important to me. So something like this: > > CayenneUtilities.batchFetch(myDataObjects, “toOne”, “toMany”). It would > execute a query to find all the objects in “toOne” for all the objects in > myDataObjects (and the same for “toMany”). Based on seeing how Cayenne > executes the prefetch queries (at least with UNDEFINED_SEMANTICS), I bet it > would be pretty straight forward. But I haven’t looked at the code enough > and it might be above my pay grade. ;) > > The downside (I think) with the way WOnder implemented it is it just uses > primary keys to find the objects (lots of ORs), so depending on your > database you had to also specify the number of myDataObjects to process at > once. > > -Lon > > On Tue, Jul 5, 2016 at 11:07 PM, Andrus Adamchik <and...@objectstyle.org> > wrote: > >> IIRC in EOF this was "probabilistic", with framework trying to guess >> which other objects' relationships to include in batch fetch. So we'd also >> need to track some kind of "affinity" of root objects between each other. >> >> The first step would be to patch Cayenne to make >> org.apache.cayenne.reflect.FaultFactory injectable (currently it is >> created inside EntityResolver). Then come up with a custom FaultFactory and >> an algorithm for tracking the affinity of faults between each other. And >> make sure it doesn't leak memory :) >> >> Andrus >> >> >> > On Jul 6, 2016, at 12:20 AM, Mike Kienenberger <mkien...@gmail.com> >> wrote: >> > >> > That'd be something I'd get some use out of as well. >> > >> > On Tue, Jul 5, 2016 at 5:19 PM, Lon Varscsak <lon.varsc...@gmail.com> >> wrote: >> >> I know I’ve asked this before, but I need a batch fetch utility class, >> to >> >> trigger batch fetching of relationships. I know pre-fetching will do >> this, >> >> but usually when I need it is after the fetch (and I don’t want to >> always >> >> do it even when it’s not needed). >> >> >> >> Anyone have any pointers on how to go about implementing this? >> >> >> >> -Lon >> >> >