Re: prefetch & many-to-many

From: Tore Halset (halse..vv.ntnu.no)
Date: Fri Nov 07 2003 - 09:13:02 EST

  • Next message: Michael Gentry: "Re: distributed transactions"

    On Fri, 7 Nov 2003, Mike Kienenberger wrote:

    > Isn't that what should happen?

    I am sorry. I did not include all of the code. The complete code looks
    like this.

    SelectQuery query = new SelectQuery(Group.class);
    query.addPrefetch("elements");
    List groups = dataContext.performQuery(query);
    for(Iterator i = groups.iterator(); i.hasNext();){
      Group g = (Group)i.next();
      List elements = g.getElements();
      System.out.println(g.getName());
      for(Iterator i2 = elements.iterator(); i2.hasNext();){
        Element e = (Element)i2.next();
        System.out.println(" " + e.getName());
      }
    }

    This will lead to one query on Group and lots of queries on Element. I
    want cayenne to perfom one query and use join to include all elements for
    all of the groups. Is it possible?

     - Tore.



    This archive was generated by hypermail 2.0.0 : Fri Nov 07 2003 - 09:13:08 EST