Thanks Marek for your suggestion.
I would still like to ask whether there are any other efficient ways
to know the count of rows in a table in cayenne.
Any ideas?
Thanks,
Rashid Khan
On 7/28/06, Marek Wawrzyczny <marek_wawrzyczn..nternode.on.net> wrote:
> Hi Rashid,
>
> The answer is yes... and I believe that the following code achieves that on
> both single and multi tier approaches (well it works on multi-tier client
> code):
>
> String entity = getContext().getEntityResolver().lookupObjEntity(
> persistentClass).getName();
> HashMap map = new HashMap();
> map.put("entityName", entity);
> addWhereClause(map);
> NamedQuery query = new NamedQuery("EntityCount", map);
> Map row = (Map) getContext().performQuery(query).get(0);
> return ((Number) row.get("C")).intValue();
>
> Then, in the modeller create the following Query, in this case it is
> called "EntityCount":
>
> SELECT #result('count(*)' 'int' 'C') FROM $entityName $whereClause
>
> Hope that helps,
>
> Marek Wawrzyczny
>
>
> On Friday 28 July 2006 16:44, Rashid Khan wrote:
> > Hello there,
> >
> > I want to know what is the most efficient way in cayenne to find out
> > how many rows I have in a table.
> >
> > Do I have to use something equivalent to the SQL statement: "SELECT
> > COUNT(*) FROM tablename"?
> >
> > Thanks,
> >
> > Rashid Khan
>
This archive was generated by hypermail 2.0.0 : Fri Jul 28 2006 - 08:34:30 EDT