Re: SQLTemplate with addPrefetch?

From: Tore Halset (halse..vv.ntnu.no)
Date: Tue Aug 24 2004 - 12:20:33 EDT

  • Next message: Andrus Adamchik: "Re: JBoss transactions"

    On Aug 24, 2004, at 14:01, Twan Kogels wrote:

    > where.add(" (opleiding.the_geom && GeometryFromText('BOX3D(" +

    Nice to see someone else playing with postgis and cayenne :)

    > Is it possible to prefetch relationships when using SQLTemplate?

    Take a look at PrefetchHelper
    http://www.objectstyle.org/cayenne/api/cayenne/org/objectstyle/cayenne/
    access/util/PrefetchHelper.html

    Try something like:
    String query=".." //query with a lot of joins and non standard where
    statements
    SQLTemplate rawSelect = new SQLTemplate(Opleiding.class, query, true);
    List opleidingen = ctxt.performQuery(rawSelect);
    PrefetchHelper.resolveToOneRelations(ctxt, opleidingen,
    "waardeopleiding");

    If I remember correctly this will result in a huge query looking like
    "select .... from table where field in (....)". This trick take some
    time if your opleidingen List is very long..

    Regards,
      - Tore.



    This archive was generated by hypermail 2.0.0 : Tue Aug 24 2004 - 12:20:42 EDT