RE: One more query

From: Fredrik Liden (flide..ranslate.com)
Date: Thu Mar 17 2005 - 18:53:24 EST

  • Next message: Andrus Adamchik: "Re: weird log entries"

    Thanks both of you.
    Good point about the DataNode because I'm using 3 different databases.
    Although what if you had a query that contains tables from various
    datanodes?

    -----Original Message-----
    From: Gentry, Michael (Contractor) [mailto:michael_gentr..anniemae.com]

    Sent: Thursday, March 17, 2005 2:43 PM
    To: cayenne-use..bjectstyle.org
    Subject: RE: One more query

    In addition to what Andrus said, if you are fetching raw rows, the first
    parameter might seem useless, but it is actually used by Cayenne to
    determine which DataNode (and therefore database connection -- important
    when you are using more than one database) to use to perform the fetch.
    So, it isn't crucial which ObjEntity to specify for the first parameter
    when fetching raw rows, as long is it is in the correct DataNode/DB.
    I'd almost prefer another constructor which could take a DataNode as the
    first parameter, since that makes more sense (and would default the
    query to raw rows then).

    So, in your example, "Irf.class" is informing Cayenne which DB to
    access, even though you aren't returning objects of "Irf". Be sure you
    fetch raw rows:

    selectQuery.setFetchingDataRows(true);

    /dev/mrg

    -----Original Message-----
    From: Fredrik Liden [mailto:flide..ranslate.com]
    Sent: Thursday, March 17, 2005 3:45 PM
    To: cayenne-use..bjectstyle.org
    Subject: One more query

    Can I use agregates like sum in an SelectQuery?

    Or should I use the SQLTemplate? One question regarding the SQLTemplate.

    Does it matter what the first parameter is? I mean since the query
    returns raw data. Oh, and what's the third parameter?

    SQLTemplate selectQuery = new SQLTemplate(Irf.class,"select
    description,sum(amount) from irf_entry group by description",true);

    Thanks!

    /Fredrik



    This archive was generated by hypermail 2.0.0 : Thu Mar 17 2005 - 18:52:33 EST