cayenne-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nikita Timofeev <ntimof...@objectstyle.com>
Subject Re: ColumnSelect API + Persistent objects
Date Thu, 09 Mar 2017 07:17:35 GMT
On Wed, Mar 8, 2017 at 3:48 AM, Aristedes Maniatis <ari@maniatis.org> wrote:
> On 7/3/17 11:12pm, Nikita Timofeev wrote:
>> 2) Add new factory methods in Property class:
>>
>>     <T extends Persistent> Property<T> createSelf(Class<? super T>
type);
>
> Why wouldn't we just use normal constructors?
>
> a = new Property(Artist.class);

That's because createSelf() method will create expression needed for
this to work.
And as mentioned in the first mail this new expression can later be
used in other ways.

>
>>     <T extends Persistent> Property<T> createForRelationship(
>>                    Property<?> property, Class<? super T> type)
>
>> 3) Prohibit direct usages of properties mapped on toMany
>> relationships, so that the following code will throw a
>> CayenneRuntimeException
>>
>> List<Object[]> result = ObjectSelect.query(Artist.class)
>>         .columns(Artist.ARTIST_NAME, Artist.PAINTING_ARRAY)
>>         .select(context);
>
> I'm confused about why we need a new type of property for this rather than just using
Artist.PAINTING_ARRAY
>

This is because PAINTING_ARRAY have List<Painting> type and we
currently can provide only Painting.
So to have proper type we need another Property to be created.
Thou it is indeed a question whether we need this at all:
a ColumnSelect result as it will be is raw SQL, i.e. in this example
Paintings not folded into a List.

For me it's not clear when do we need direct List result for toMany
relationship instead of using Prefetch (or even selecting related
entities explicitly).

-- 
Best regards,
Nikita Timofeev

Mime
View raw message