Hi all, I'm currently working on some missing parts of ColumnSelect API introduced in M5.
Idea is simple: select full entities along with arbitrary columns. It was discussed previously on @dev list, thou without any details. These entities can be anything that can be resolved against root (root itself, toOne or toMany relationships) * The suggested changes in API is following * 1) Add new Expression ASTFullObject (and the corresponding method in ExpressionFactory) that will be just a marker for the desired logic. This expression can be later (in post 4.0 versions) used in where() and in orderBy() methods where it can act as ObjectId and thus fill another gap where hacks with paths like "db:OBJECT_ID" are used now. 2) Add new factory methods in Property class: <T extends Persistent> Property<T> createSelf(Class<? super T> type); <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); * Usage examples * 1) Selecting root object plus some related fields: Property<Artist> artistSelf = Property.createSelf(Artist.class); List<Object[]> result = ObjectSelect.query(Artist.class) .columns(artistSelf, Artist.ARTIST_NAME, Artist.PAINTING_ARRAY.count()) .select(context); 2) Selecting toOne relationship: // Here Object[1] will be an Artist, Object[2] will be a Gallery List<Object[]> result = ObjectSelect.query(Painting.class) .columns(Painting.PAINTING_TITLE, Painting.TO_ARTIST, Painting.TO_GALLERY) .select(context); 3) Selecting toMany relationship (this is a questionable feature) The result will be as it would be in raw SQL query (i.e. flat matrix of Artists and Paintings) Property<Artist> artist = Property.createSelf(Artist.class); Property<Painting> artistPainting = Property.createForRelationship(Artist.PAINTING_ARRAY, Painting.class); Property<Gallery> artistPaintingGallery = Artist.PAINTING_ARRAY.dot(Painting.TO_GALLERY); List<Object[]> result = ObjectSelect.query(Artist.class) .columns(artist, artistPainting, artistPaintingGallery) .select(context); Any comments, usage scenarios, naming suggestions, etc will be really appreciated! Here is a link to the corresponding JIRA issue: https://issues.apache.org/jira/browse/CAY-2255 -- Best regards, Nikita Timofeev