Re: prefetch & many-to-many

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Nov 07 2003 - 12:40:30 EST

  • Next message: Andrus Adamchik: "Re: Searching Object Cache"

    On Nov 7, 2003, at 4:31 AM, Tore Halset wrote:

    > Hello!
    >
    > DB-relation:
    > Group<-->>GroupHasElement<<-->Element
    >
    > OO-relation (flattened relationship):
    > Group<<-->>Element
    >
    > I want to query for all groups and prefetch elements, but the prefetch
    > does not happen
    >
    > SelectQuery query = new SelectQuery(Group.class);
    > query.addPrefetch("elements");
    > List groups = dataContext.performQuery(query);
    >
    > Result in one query on group and lots of queries on element. Am I doing
    > anything wrong?

    At the moment prefetching does not work for flattened relationships (I
    guess we should mention it in the docs and open the bug report). There
    are some limitations in the currently used algorithm for prefetching
    that prevent it from handling flattened relationships properly (strange
    though, I see 2 queries executed in my test cases... only the target
    array of to-many is not initialized properly, even though the prefetch
    query returns correct result).

    I'll see if this can be fixed without too much disturbance to the
    STABLE branch. If we can do that, I hope to get it released as 1.0.x,
    if not - 1.1

    Andrus



    This archive was generated by hypermail 2.0.0 : Fri Nov 07 2003 - 12:40:34 EST