cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: questions
Date Wed, 13 Feb 2008 19:36:18 GMT
On Feb 13, 2008, at 1:48 PM, Eric Polino wrote:
> 1.  How do I count the rows of a query, without actually doing a full
> blown SelectQuery and counting the elements?  ie: select count(*) from
> table;

For aggregate queries I suggest EJBQLQuery (only available in 3.0)...  
It uses the same approach of joins expressed as relationships as  
SelectQuery, only it also allows aggregate expressions. E.g.:

    EJBQLQuery query = new EJBQLQuery("select count(a) from Artist a  
WHERE a.artistName like 'X%'");
    Number count = (Number) DataObjectUtils.objectForQuery(query);


View raw message