Re: Question

From: Andrus (andru..bjectstyle.org)
Date: Sat Aug 10 2002 - 12:56:03 EDT

  • Next message: 'CAMILLE CAMPAGNE': "informations"

    Hi Len,

    At 09:37 PM 8/10/2002 +0300, Marilen Corciovei wrote:
    >Hi,
    >
    >I'm Len. For a long time now i'm looking for an usable and speed eficient
    >object mapping to databases. I found your project a few days ago and i'm
    >preaty impressed. I have a question:
    >
    >- Starting from a sql file to an object mapping is there any option to
    >have something like: "select p.name a.name from artist a, painting p where
    >p.artist_id=a.artist_id."

    Yes, there is a feature called "prefetching":

    http://objectstyle.org/cayenne/api/org/objectstyle/cayenne/query/SelectQuery.html#addPrefetch(java.lang.String)

    This is exactly what you are looking for. Now, there is a bug in current
    release: prefetching has no effect on "to many" relationships. It will be
    fixed soon. But "to one" do work well, so fetching from the "Painting"
    should give you the needed effect:

    SelectQuery q = new SelectQuery("Painting");

    // Add prefetching of "toARtist" relationship
    q.addPrefetch("toArtist");
    List paints = context.performQuery(q);

    Painting p1 = (Painting)paints.get(0);

    // this is already resolved in memory die to prefetch
    Artist a1 = p1.toArtist();

    Regards
    Andrus



    This archive was generated by hypermail 2.0.0 : Sat Aug 10 2002 - 12:55:59 EDT