cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <>
Subject Re: SQLSelect: Getting fluent… WDYT?
Date Sat, 25 May 2013 07:33:03 GMT
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

     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()


Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message