Re: Problems to execute(SELECT MAX).

From: Tore Halset (halse..vv.ntnu.no)
Date: Fri Jul 30 2004 - 11:07:36 EDT

  • Next message: Gentry, Michael: "RE: Problems to execute(SELECT MAX)."

    Hello

                    String q = "select max(field) as max from table";
                    SQLTemplate query = new SQLTemplate(Table.class, q, true);
                    query.setFetchingDataRows(true);
                    List result = dc.performQuery(query);
                    Map row = (Map)result.get(0);
                    log.info("max: " + row.get("max"));

    Take a look at aggregate-functions in cayenne examples as well:
    http://objectstyle.org/cayenne/examples/aggregate-functions/index.html

    Regards,
      - Tore.

    On Jul 30, 2004, at 15:52, Reinaldo Coelho Sartorelli wrote:

    > Regards, you have a example?
    >
    > I can't execute SELECT MAX with the SqlTemplate option and neither with
    > Expression as was suggested in the other email.
    >
    > Tks,
    > Reinaldo.
    >
    > On Friday 30 July 2004 03:08, Tore Halset wrote:
    >> On Jul 30, 2004, at 3:22, Reinaldo Coelho Sartorelli wrote:
    >>> All, who i can execute SELECT MAX from column, if "SqlSelectQuery" is
    >>> deprecated, and don't have MAX option ???
    >>
    >> Take a look at SQLTemplate. It has replaced SqlSelectQuery and has
    >> some
    >> nice features.
    >> http://www.objectstyle.org/cayenne/userguide/fetch/sqltemplate.html
    >>
    >> Does cayenne support using a attribute based on a function like min,
    >> max, sum, count and avg in the model? The attribute needs to be read
    >> only and should not be included when the table are created. I think
    >> this is supported by EOF. The argument to the function could be a
    >> path.
    >> E.g: The Company ObjEntity could have a attribute named maxSallery
    >> defined as max(employe.sallery).
    >>
    >> Regards,
    >> - Tore.



    This archive was generated by hypermail 2.0.0 : Fri Jul 30 2004 - 11:07:33 EDT