cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: API for aggregate and non aggregate SQL functions
Date Sat, 07 Jan 2017 14:25:02 GMT

> On Jan 7, 2017, at 5:03 PM, Nikita Timofeev <> wrote:
>> would a map be more useful to return than this tuple style approach? Java's collections
are a bit clunky, but:
>> Map<PersistentObject, Object[]> result2 = ObjectSelect.query(Artist.class)
>>                .columns(Artist.ARTIST_NAME, paintingCountProperty)
>>                .having(
>>                .select(context);
> I'm not sure that Map<> will be a good approach to the problem.
> We actually discussed with Andrus how PersistentObject can be returned
> with columns() method.
> And we decided that it will be better to define explicitly that you
> want PersistentObject in result:
> Property<Artist> artistSelf = Property.create("hollowArtist", ?some
> expression?, Artist.class);
> List<Object[]> result2 = ObjectSelect.query(Artist.class)
>                .columns(Artist.ARTIST_NAME, artistSelf, paintingCountProperty)
>                .having(
>                .select(context);

Yeah, at this point we are constrained with the core return formats that are supported elsewhere
in Cayenne (which are already pretty complex). We may (and will need to) rethink it in the
later versions. But for 4.0 I suggest that we avoid any more redesign that will delay the
release. As a reminder the current format is this:

List<? extends Persistent>
List<Object> // a list of scalars
List<Object[]> // a list of Object[] with each array column being Persistent|DataRow|scalar

Of course any of these can be easily converted to desired representations with simple functional
one-liners by the users.


View raw message