Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 98610200B45 for ; Fri, 15 Jul 2016 20:10:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 96DE5160A61; Fri, 15 Jul 2016 18:10:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E1724160A57 for ; Fri, 15 Jul 2016 20:10:50 +0200 (CEST) Received: (qmail 86143 invoked by uid 500); 15 Jul 2016 18:10:50 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 86130 invoked by uid 99); 15 Jul 2016 18:10:49 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jul 2016 18:10:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 67FFEC0472 for ; Fri, 15 Jul 2016 18:10:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.198 X-Spam-Level: * X-Spam-Status: No, score=1.198 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id DCagb4HCFun3 for ; Fri, 15 Jul 2016 18:10:45 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 112855FE24 for ; Fri, 15 Jul 2016 18:10:45 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id s63so108627436qkb.2 for ; Fri, 15 Jul 2016 11:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Om4uHNvE/j4oGD/dXRwqbGGAdSPOzjS9NuZ47o/fM1A=; b=JxdBDM54NkvbhwH48iSnaTBYMzL4oDRo+mfvmssLhYlVMINq0xlUCfDx6jUtCKHW+d hS3G3qHJ25BeHJ6wO2KuVNXdrx7taZstWLlka7IYXKXbzCW7tNdVNwknoIY/LSV5O2ek eNUzI1V+Cyf9yXAINmh4J2rhNi53akEIJE4YDH3N162gz5TuFJEzaFoFQgO4UE13ymzO fU/cDcbvl+mZbjvUOuiDYORzbvmgOVIBpCSKyRzTHEN+uPKLBbBp8LfCSoBonSl6FAIB axTrQNuM4BXNQ9ojpupgQVEewYD2Czw9y5gtwK8J2Z8vM/fZ8+3jvhpkmh9ncDfoV5zo HJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Om4uHNvE/j4oGD/dXRwqbGGAdSPOzjS9NuZ47o/fM1A=; b=ZJkPQrT2k6/KHK5fCHCzRT1EhUQXUN/PAWI6zPEFN4tXsnhyzjDsET/GXNithTTPt2 nmWKhHOK86iwAs33v1n9YalLCCZFlqttIl0vw4xTOxutNctCWHCNNZNVERW6UTY0i9t4 OLpBmsbg8+Go1tlI0AK0MRiqQgCQKAg9W6GdmkMhbMxltPt2bGMpRVmBx4pZmBW5+tCa mgv392tHZqcR4wtkhHmfqfTrdVI/A6ghBS/RCeVH43ScyCHTaqNhAXtSE/lLXvMN+n+z mQn4K7jqcB5vzxa5n22LCncSNYoAR+8/eAPU40iTue7z/XHViQCml6UsC0fZW3VLUXui 7dSw== X-Gm-Message-State: ALyK8tIXa2eVWDWlmAMcdizJp718pvRq9szb3LzEo3uavGov2C9Hjzf4YXYmlTx1DP/3+Q2kNn+Z05u43Ca08Q== X-Received: by 10.55.162.138 with SMTP id l132mr25588125qke.85.1468606244138; Fri, 15 Jul 2016 11:10:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: John Huss Date: Fri, 15 Jul 2016 18:10:34 +0000 Message-ID: Subject: Re: Aggregate function To: user@cayenne.apache.org Content-Type: multipart/alternative; boundary=001a114fb5387f35420537b0896a archived-at: Fri, 15 Jul 2016 18:10:51 -0000 --001a114fb5387f35420537b0896a Content-Type: text/plain; charset=UTF-8 You have to call query.setFetchesDataRows(true) On Fri, Jul 15, 2016 at 1:08 PM John Huss 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 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 wrote: >> >> > Make sure your sqltemplate us set to fetch datarows (hashmap) not >> objects >> > On Fri, Jul 15, 2016 at 12:27 PM Harunobu Oyama wrote: >> > >> > > Michael, >> > > >> > > The min connection and max connection are both 1 as default. >> > > >> > > nobu >> > > >> > > >> > > On 15 July 2016 at 18:16, Michael Gentry wrote: >> > > >> > > > On Fri, Jul 15, 2016 at 12:39 PM, Harunobu Oyama >> > 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 >> > > > >> > > >> > >> > --001a114fb5387f35420537b0896a--