Just committed basic scalar API:
int c = SQLSelect.scalarQuery(Integer.class, "")
.append("SELECT COUNT(*) FROM ARTIST")
.selectOne(context);
List<Long> ids = SQLSelect.scalarQuery(Long.class, "SELECT ARTIST_ID FROM
ARTIST ORDER BY ARTIST_ID").select(context);
and documented the remaining enhancements per CAY-1830.
Andrus
On May 25, 2013, at 1:39 PM, Andrus Adamchik <[email protected]> wrote:
>
> On May 25, 2013, at 10:33 AM, Aristedes Maniatis <[email protected]> wrote:
>
>
>> 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.
>
> Guessing it in Cayenne would be ideal. The feature itself dates back to
> SQLTemplate, but the new API is all about making things easier. The goal of
> this feat is to be able to convert DataRow to object, so we presumably know
> the entity involved and can make a good guess.
>
>> 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).
>
> Yeah, I'd say we should start supporting positional parameters (and we do in
> EJBQL, but not in SQLTemplate or Expression). Then it will work with a vararg
> method.
>
>
>> 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()
>
> Good idea. It should be easy to do.
>
> Andrus
>
>