> On Mar 9, 2017, at 10:17 AM, Nikita Timofeev <ntimof...@objectstyle.com> > wrote: > > On Wed, Mar 8, 2017 at 3:48 AM, Aristedes Maniatis <a...@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.
So if we call it just "create(Class)" instead of "createSelf", will it cause any ambiguity? >>> <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). So while I understand what we are trying to do with "createForRelationship" (this is a "flatMap"-like transformation), I am wondering how we can make the semantics more transparent? Perhaps we add "flat()" method to the Property itself: Property<List<Painting>> listProperty = Artist.PAINTING_ARRAY; Property<Painting> objectProperty = listProperty.flat(); // or 'flatMap'? Andrus