John,
The following code showed "The result was a null" message.
SQLTemplate query = new SQLTemplate( Reading.class, "SELECT
MAX(\"reading_id\") FROM \"reading\"" );
List result = context.performQuery( query );
result.forEach( r -> {
if ( r == null ) {
System.out.println( "The result was a null" );
} else {
System.out.println( r.toString() );
}
} );
nobu
On 15 July 2016 at 18:05, John Huss <[email protected]> wrote:
> You need to call context.performQuery NOT performGenericQuery.
>
> On Fri, Jul 15, 2016 at 4:56 AM Harunobu Oyama <[email protected]> wrote:
>
> > Hi,
> >
> > What is the Cayenne way to execute aggregate functions?
> >
> > For example, SELECT MAX("reading_id") FROM "reading" ?
> >
> > I tried passing SQLTemplate containing the SQL written above
> > to performGenericQuery method, with no luck. Are we supposed to use JDBC?
> > If so, what is the best way to get the JDBC Connection?
> >
> > Any hint would be appreciated.
> >
> > thank you,
> > nobu
> >
>