cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Borut BolĨina" <borut.bolc...@gmail.com>
Subject Re: newbie question
Date Tue, 22 Apr 2008 11:47:47 GMT
Hello Andrus,

what is the elegant 3.0M3 Cayenne way to do select MAX?

Thanks,
Borut

2007/10/9 Andrus Adamchik <andrus@objectstyle.org>:

> Hi Jan,
>
> Looks like what you need is a SQLTemplate query:
>
>   http://cayenne.apache.org/doc/sqltemplate-query.html
>
> Here is a mockup code example:
>
>  SQLTemplate q = new SQLTemplate(SomeClass.class, "select MAX(id) from
> table");
>  q.setFetchingDataRows(true);
>
>  Map row = (Map) DataObjectUtils.objectForQuery(q);
>  Number id = (Number) row.values().iterator().next();
>
> (Cayenne 3.0 will be featuring more elegant API to achieve that, but still
> the code above should work just as well)
>
> Andrus
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message