cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: Aggregate function
Date Fri, 15 Jul 2016 18:10:34 GMT
You have to call query.setFetchesDataRows(true)
On Fri, Jul 15, 2016 at 1:08 PM John Huss <johnthuss@gmail.com> wrote:

> That's the query you don't want. You want a DataRow object not a Reading.
> On Fri, Jul 15, 2016 at 12:58 PM Harunobu Oyama <ho@telensa.com> wrote:
>
>> John,
>>
>> So, there is no Cayenne native way to perform a query such as SELECT
>> MAX("reading_id") FROM "reading"  ?
>> It sounds like you are recommending to write another query to fetch a
>> record with max reading_id instead.
>>
>> Indeed, the code below worked.
>>
>>   SQLTemplate query = new SQLTemplate( Reading.class, "SELECT * FROM
>> \"reading\" WHERE \"reading_id\"=( SELECT MAX(\"reading_id\") FROM
>> \"reading\" )" );
>>   List result = context.performQuery( query );
>>
>> thank you,
>> nobu
>>
>>
>>
>>
>> On 15 July 2016 at 18:35, John Huss <johnthuss@gmail.com> wrote:
>>
>> > Make sure your sqltemplate us set to fetch datarows (hashmap) not
>> objects
>> > On Fri, Jul 15, 2016 at 12:27 PM Harunobu Oyama <ho@telensa.com> wrote:
>> >
>> > > Michael,
>> > >
>> > > The min connection and max connection are both 1 as default.
>> > >
>> > > nobu
>> > >
>> > >
>> > > On 15 July 2016 at 18:16, Michael Gentry <blacknext@gmail.com> wrote:
>> > >
>> > > > On Fri, Jul 15, 2016 at 12:39 PM, Harunobu Oyama <ho@telensa.com>
>> > wrote:
>> > > >
>> > > > > Caused by: java.sql.SQLException: Can't obtain connection. Request
>> > > timed
>> > > > > out. Total used connections: 1
>> > > > > at
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>> org.apache.cayenne.conn.PoolManager.uncheckPooledConnection(PoolManager.java:454)
>> > > > > at
>> > > >
>> org.apache.cayenne.conn.PoolManager.getConnection(PoolManager.java:382)
>> > > > > at
>> > > >
>> org.apache.cayenne.conn.PoolManager.getConnection(PoolManager.java:371)
>> > > > > at
>> > > > >
>> > > > >
>> > > >
>> > >
>> >
>> org.apache.cayenne.configuration.server.DefaultDbAdapterFactory.detectAdapter(DefaultDbAdapterFactory.java:97)
>> > > > > ... 15 more
>> > > >
>> > > >
>> > > > Hi Nobu,
>> > > >
>> > > > Given this part of the exception, it seems it was unable to get a
>> > > > connection to the database.  How is your connection pool configured?
>> > Do
>> > > > you only have one connection?
>> > > >
>> > > > mrg
>> > > >
>> > >
>> >
>>
>

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