RE: Problems to execute(SELECT MAX).

From: Gentry, Michael (michael_gentr..anniemae.com)
Date: Fri Jul 30 2004 - 11:55:57 EDT

  • Next message: Eric Schneider: "Re: Problems to execute(SELECT MAX)."

    Maybe it's just me (too bad Andrus is on vacation right now), but if you
    are passing in the entity to the SQLTemplate constructor, why do you
    also need to include a "from" clause? Seems to me it should be able to
    figure that out and could do it better than us developers (especially
    where the database is case sensitive, such as Sybase or the table name
    is different/confusing compared to the entity name). After all, that
    information has already been modeled.

    Am I missing something there or does anyone else find that strange?

    Thanks,

    /dev/mrg

    -----Original Message-----
    From: Tore Halset [mailto:halse..vv.ntnu.no]
    Sent: Friday, July 30, 2004 11:08 AM
    To: Cayenne mailing list post
    Subject: 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:56:06 EDT