> It'd be worth adding support for not only count but avg, max, min,
> sum operations on keys... like: people..vg.age.
Sure, but my point was that query should not run itself. Hence the
separation between the query and its execution logic.
> Maybe the class I posted beforehand could be easily morphed into
> such a query helper(?).
Yes - in defining CountQuery, MaxQuery, etc. it seems like what we need.
> 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.
I was thinking that DataObjectUtils.intValueForQuery proposed below
would do the unwrapping of the map into a scalar value. It can do it
in a generic fashion as long as there's only one key in the returned
map.
Andrus
On Jun 4, 2007, at 10:30 AM, Lachlan Deck wrote:
> 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: people..vg.age.
>
> 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
>
>
>
>
This archive was generated by hypermail 2.0.0 : Mon Jun 04 2007 - 03:40:37 EDT