cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Hartmann <>
Subject Create count(*) query based on SelectQuery
Date Wed, 20 Jan 2010 16:10:43 GMT
Hi everyone,

I'm mainly using SelectQuery queries, built using quite a complex 
programmatic infrastructure. But now I have the requirement to obtain 
the total number of rows (to set the Content-Range header in a REST 

So basically I have a SelectQuery which does

   SELECT … FROM foo WHERE <whereClause> LIMIT … OFFSET …;

and I need

   SELECT count(*) FROM foo WHERE <whereClause>;

Is there a straightforward way to build such a query based on the 
SelectQuery's expression? I tried Expression.toEJBQL() but faced a 
couple of problems which have already been described on this list (e.g. 
the likeIgnoreCase issue).

Do I really have to build a string-based SQL or EJBQL query from scratch?

Thanks a lot for any hints!

Best regards,

Andreas Hartmann, CTO
BeCompany GmbH
Tel.: +41 (0) 43 818 57 01

View raw message