Hi Ari,

Perhaps a bit off topic (since I haven't really reviewed the class Andrus
posted yet), but I've already written some code for aggregates
(count/min/max/sum/avg) if anyone wants to use it.

Main project:
https://github.com/mrg/cbe/tree/master/FetchingObjects/Aggregates

Example using it:
https://github.com/mrg/cbe/blob/master/FetchingObjects/Aggregates/src/main/java/cbe/fetching/Aggregates.java

mrg



On Sat, May 25, 2013 at 3:33 AM, Aristedes Maniatis <a...@maniatis.org>wrote:

> On 25/05/13 1:45am, Andrus Adamchik wrote:
>
>> I can think of other methods for building SQL chunks based on Cayenne
>> mapping, such as "allColumns()", etc.
>>
>> What do you think? Also method naming criticism is accepted. E.g. I am
>> not sure that changing "setPageSize()" to "pageSize()" was such a great
>> idea.
>>
>
> I think that in a fluent api, removing "set" before every method is
> clearer. Then you will have:
>
>     Artists<List> artists = SQLSelect.query(Artist.class, "SELECT * FROM
> Artists WHERE name = $name").bind("name", "fred").pageSize(10).**
> cacheGroups("main").select()
>
>
> However I am confused by columnNameCaps(). This seems to be something
> you'd want to set in the data model rather than per query. Or could Cayenne
> just perform a case insensitive match to the db model and then adjust the
> case as needed, all without specifying anything.
>
> Also, does it make sense to allow the bindings within the query method as
> an option:
>
>     SQLSelect.query(Artist.class, "SELECT * FROM Artists WHERE name =
> $name", "name", "fred")
>
> That's a bit like printf style calls (although it references replacements
> by position rather than name).
>
>
>
> Would it be possible to write aggregate queries:
>
>     int count = SQLSelect.scalar(Artist.class, "SELECT COUNT(*) FROM
> Artists WHERE name = $name").bind("name", "fred").value()
>
>
>
> Ari
>
>
>
> --
> -------------------------->
> Aristedes Maniatis
> GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
>

Reply via email to