Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 55130 invoked from network); 20 Jan 2010 16:23:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Jan 2010 16:23:29 -0000 Received: (qmail 69840 invoked by uid 500); 20 Jan 2010 16:23:28 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 69823 invoked by uid 500); 20 Jan 2010 16:23:28 -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 69813 invoked by uid 99); 20 Jan 2010 16:23:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jan 2010 16:23:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 20 Jan 2010 16:23:17 +0000 Received: (qmail 4926 invoked from network); 20 Jan 2010 16:22:55 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 20 Jan 2010 16:22:55 -0000 Message-Id: <742FC561-950F-466F-BB1B-40EF7F234F78@objectstyle.org> From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Create count(*) query based on SelectQuery Date: Wed, 20 Jan 2010 18:22:54 +0200 References: X-Mailer: Apple Mail (2.936) X-Virus-Checked: Checked by ClamAV on apache.org Short of writing custom extensions of SelectQuery, yes, EJBQL or =20 SQLTemplate is the answer. We are designing a combined SelectQuery / EJBQLQuery that can be =20 created either via String or using API as a part of 3.1, but in 3.0 =20 this is not an option. Andrus On Jan 20, 2010, at 6:10 PM, Andreas Hartmann wrote: > Hi everyone, > > I'm mainly using SelectQuery queries, built using quite a complex =20 > programmatic infrastructure. But now I have the requirement to =20 > obtain the total number of rows (to set the Content-Range header in =20= > a REST service). > > So basically I have a SelectQuery which does > > SELECT =85 FROM foo WHERE LIMIT =85 OFFSET =85; > > and I need > > SELECT count(*) FROM foo WHERE ; > > Is there a straightforward way to build such a query based on the =20 > SelectQuery's expression? I tried Expression.toEJBQL() but faced a =20 > couple of problems which have already been described on this list =20 > (e.g. the likeIgnoreCase issue). > > Do I really have to build a string-based SQL or EJBQL query from =20 > scratch? > > Thanks a lot for any hints! > > Best regards, > Andreas > > > > --=20 > Andreas Hartmann, CTO > BeCompany GmbH > http://www.becompany.ch > Tel.: +41 (0) 43 818 57 01 > >