getting max() using SelectQuery

From: Stefan Michel (stefan.miche..xedio.com)
Date: Wed Feb 04 2004 - 09:57:12 EST

  • Next message: Andrus Adamchik: "Re: getting max() using SelectQuery"

    I want to query the max value of the column number (Long=BIGINT) in
    table incident .
    I did manage to get this via raw sql using SqlSelectQuery "SELECT
    MAX(number) FROM Incident"
    However would like to get the max value on the object query level.

    I want something like this:
          Expression exp=ExpressionFactory.unaryExp(Expression.MAX,
    IncidentImpl.NUMBER_PROPERTY );
          SelectQuery query = new SelectQuery(IncidentImpl.class,exp);
          List data = ctx_.performQuery(query);
    The above gives the following exception
         [java] Caused by: org.postgresql.util.PSQLException: ERROR: invalid
    input syntax for type boolean: "number"
         [java] at
    org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
    (number is a Long on obj level - a BIGINT on DB level - getter and
    setter are working- the raw max query is working to)

    Does anyone know how to query the max value on an object level ?

    The following thread dealt with the same problem, but the proposed
    solution was a raw sql query:
    http://www.objectstyle.org/cayenne/lists/cayenne-user/2003/09/0062.html



    This archive was generated by hypermail 2.0.0 : Wed Feb 04 2004 - 09:57:04 EST