Hello Andrus,

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

Thanks,
Borut

2007/10/9 Andrus Adamchik <[EMAIL PROTECTED]>:

> 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
>

Reply via email to