I use an SQLTemplate to retrieve sizes. I'm 99% certain Cayenne would
have to fetch all rows to give you the size using a regular SelectQuery.
For Sybase (you'll have to tailor it for MySQL, probably), I used
something like:
final String queryString = "SELECT count(*) 'rowCount' from Foo where
bar = $bar";
final SQLTemplate queryTemplate = new SQLTemplate(Foo.class,
queryString, true);
queryTemplate.setFetchingDataRows(true);
Map queryParameters = new HashMap(1);
queryParameters.put("bar", "xyzzy");
SQLTemplate query = queryTemplate.queryWithParameters(queryParameters);
List results = dataContext.performQuery(query);
if (results.size() == 1)
return results.get(0).get("rowCount").intValue();
else
return 0;
-----Original Message-----
From: Gili [mailto:cowwo..bs.darktech.org]
Sent: Tuesday, September 20, 2005 10:49 AM
To: cayenne-use..bjectstyle.org
Subject: Re: How to do these two tasks properly in cayenne?
For #1, I believe it is possible to create a SelectQuery for the
table
in question, and invoke size() on the resulting size(). My guess is that
Cayenne will be smart enough to invoke "select count(*)" without
actually retrieving the actual rows.
Gili
Tore Halset wrote:
> On Sep 20, 2005, at 9:26, Tomas Jucius wrote:
>
>> I wanted to know how properly to do these:
>>
>> 1) count rows in the table
>> 2) execute "password" function and get result..
>>
>> DataBase: MySql..
>>
>> Is it possible with cayenne to execute simple query and get result
map?
>
>
> Yes, using SQLTemplate
>
> http://www.objectstyle.org/cayenne/userguide/fetch/sqltemplate.html
>
> - Tore.
>
-- http://www.desktopbeautifier.com/
This archive was generated by hypermail 2.0.0 : Tue Sep 20 2005 - 11:05:31 EDT