Re: flattened prefetches

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Oct 03 2005 - 17:05:16 EDT

  • Next message: Cris Daniluk: "Re: flattened prefetches"

    Yeah, joint prefetches are needed in case of flattened. Look at it
    from the DB perspective - if there are two related tables and neither
    of them has an FK to another one, you have to have a join somewhere
    to figure it out. In Cayenne terms, person row snapshot doesn't have
    enough info to figure out related city ObjectId.

    Optimizing an algorithm is another story... There are a few options
    that we may want to implement (e.g. prefetch on DB expression that
    has no ObjEntity to support prefetch of a joint table and relying on
    object faulting to fully resolve related targets). This needs more
    work for sure.

    Also I am still having doubts about the actual API... rules for when
    to use a regular prefetch and when to go for a joint one are not
    simple and clear. Some of them are related to Cayenne limitations,
    some - to relational db properties. I don't want users to deal with
    it in most common cases. So I was thinking of redesigning the API to
    let Cayenne decide what type of prefetch to use by default:

    query.addPrefetch(String); // Cayenne decides which one to use
    query.addPrefetch(String, int type); // User decides which type to use

    Andrus

    On Oct 3, 2005, at 4:43 PM, Cris Daniluk wrote:

    > I can't locate the question either :)
    >
    > The problem is that from my perspective, the joint prefetch doesn't
    > always make the most sense - in my case, I have tens of thousands of
    > "persons" and about 5 "cities". The joint prefetch is going to require
    > me to retrieve cities over and over again.
    >
    > The regular prefetch actually "works", executing the proper query, but
    > for some reason, it doesn't populate the flattened relationship in the
    > object itself.



    This archive was generated by hypermail 2.0.0 : Mon Oct 03 2005 - 17:05:18 EDT