cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikita Timofeev <>
Subject Re: Column select API - fetch return types
Date Mon, 16 Jan 2017 13:19:19 GMT
I think your confusion is from the bug that I'm trying to solve right
now: single argument in columns() method leads to erroneous result:
return type is declared like Object[] but actual result is single
This shouldn't happen as columns() method should always return
Object[] regardless argument count. Only way to have single Object in
result is explicitly call column() or corresponding factory method
ColumnSelect.query(EntityClass.class, singleProperty).

And I'm implementing fetchDataRow() support for the ColumnSelect too.

So I hope it will reduce inconsistency in new API.

On Mon, Jan 16, 2017 at 12:41 PM, Hugi Thordarson <> wrote:
> Hi all,
> I’ve been using the new column select API for the past week days and I’m loving it
so far.
> One thing that I find a little bothersome (and at times confusing) when using these APIs
though is how return types change based on what you’re fetching, especially how the type
will change between List<Object> to List<Object[]> based on if I’m fetching
multiple columns or a single column (I see this was discussed a little on the list the other
day). As an API consumer I think it would be much nicer if fetches consistently returned List<Object[]>.
> If this isn’t possible, might a possible workaround be to make DataRow fetches always
return DataRows? That would allow me to stick to a single API and have consistent results
from fetches, regardless of whether I’m limiting myself to a set of columns. Example:
>                 List<DataRow> list = ObjectSelect.dataRowQuery( Entry.class )
>                                 .where( Receipt.USER ).dot( User.NAME
).eq( "Hugi Þórðarson" ) )
>                                 .columns( Entry.TEXT, Entry.PRICE )
>                                 .select( someObjectContext() );
>                 for( DataRow entry : list ) {
>                         System.out.println( entry.get( "text" ) );
>                 }
> Cheers,
> - hugi

Best regards,
Nikita Timofeev

View raw message