cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: counting rows
Date Mon, 23 Jul 2007 14:47:11 GMT
And another 3.0 plug :-)

Admittedly getting results of scalar queries as Maps can be  
confusing, as (a) you have to unwrap them and (b) it is not always  
clear what the map keys are. So we are experimenting with a different  
presentation of the results. There's more work to be done on that,  
but you can do this already:

  String ejbql = "select count(p) from Painting p";
  EJBQLQuery query = new EJBQLQuery(ejbql);

  Number count = (Number) DataObjectUtils.objectForQuery(context,  
query);

Andrus


On Jul 23, 2007, at 4:57 PM, Aristedes Maniatis wrote:

>
> On 23/07/2007, at 8:49 PM, Jack O'Connor wrote:
>
>> Or something similar, that quickly returns the number of rows from  
>> a select query?
>
> If you don't need the actual records, but just the count, then you  
> can use one of the several mechanisms to do this. Here's one:
>
> http://cayenne.apache.org/doc/customizing-queries.html
>
>
> Ari Maniatis
>
>
> -------------------------->
> Aristedes Maniatis
> phone +61 2 9660 9700
> PGP fingerprint 08 57 20 4B 80 69 59 E2  A9 BF 2D 48 C2 20 0C C8
>
>


Mime
View raw message