Hi there,
On 04/06/2007, at 5:05 PM, Andrus Adamchik wrote:
We do have utility classes already, like DataObjectUtils (which are
mainly containers for static methods -- aka functions). This
would be
a "real" class (or extension of an existing class), though.
I am with Matt on the point that any new utility should preferably
stay within the well understood framework concepts. A query that
runs itself is definitely NOT something Cayenne has ever done. I
think we can squeeze it in the current framework, tweaking what has
been already proposed - a CountQuery, by adding a new method to
DataObjectUtils: intValueForQuery (analogous to existing
"objectForQuery"). So one can do:
Query q = new CountQuery(Artist.class, qualfier);
int count = DataObjectUtils.intValueForQuery(context, q);
It'd be worth adding support for not only count but avg, max, min,
sum operations on keys... like: [EMAIL PROTECTED]
Maybe the class I posted beforehand could be easily morphed into such
a query helper(?).
I think the query needs to return 1 object in the list of results
which is a Number rather than returning a Map where there's an
element with key 'C' (which is fine for sql template operations but
I'd have thought the point of a stats helper would be to abstract
that kind of stuff.
with regards,
--
Lachlan Deck