Hi,
Just to let you know, I've just recently been working on fixing up
the prefetching code, and anticipate committing my fixes in the next day
or two (definitely within the week, if things don't go quite so well :-))
While these fixes kind of overlap with the PrefetchHelper class below, I
think that it would be great to incorporate Ardnt's code somewhere. I see
it as being useful when you have a List of objects previously fetched,
possibly combined from multiple original queries, or any other manner
(DataContext.registeredObject() etc.). In that case, traditional
prefetching would be rather useless (you'd have to create a SelectQuery
which finds all the objects in your existing list, fetches them and
prefetches the related objects). However, the code below would "Just
Work"(tm).
WHere it should go, I'm not sure. DataContext may be the appropriate
place (similar to where EOF puts it's equivalent functionality, although i
think it's in a lower level of the db-stack). I don't think a separate
class is necessary (although it was convenient for Arndt, so that's not a
criticism).
Craig
On Sat, 1 Mar 2003, Arndt Brenschede wrote:
> For the two problems
>
> - prefetching relations
>
> PrefetchHelper.resolveToOneRelations(
> DataContext context,
> List objects,
> String relName
> );
>
> PrefetchHelper.resolveToManyRelations(
> DataContext context,
> List objects,
> String relName
> );
>
> This is possibly less elegant than attaching the
> prefetch-info on the query, but very flexibel.
> (How can an Iterated Query deal with prefetches?)
>
> With these two methods I can e.g. collect 100
> objects from an iterated query and then prefetch
> their relations, which resolves into
> SELECT ... WHERE GALLERY_ID IN (?, ?, ?, ?, ... )
>
> (For the twoMany, it's like that, but that doesn't
> work for compound keys. For the toOne, I used
> QueryHelper.selectQueryForIds(oids), which resolves
> into "OR ( GALLERY_ID = ? ) OR GALLERY_ID = ? ) OR ... ",
> which is frightening when you see the query, but
> similar in performance)
>
This archive was generated by hypermail 2.0.0 : Sat Mar 01 2003 - 17:14:46 EST