Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Changes in API:
- Add new Expression ASTFullObject 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 to act as ObjectId and
thus fill another gap where hacks like "db:OBJECT_ID" are used now. - Add new methods in Property:
static <T extends Persistent> Property<T> createSelf(Class<? super T> type); <T extends Persistent> Property<T> flat(Class<? super T> tClass)
- Prohibit direct usage 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:
- 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);
- Selecting toOne relationship:
List<Object[]> result = ObjectSelect.query(Painting.class) .columns(Painting.PAINTING_TITLE, Painting.TO_ARTIST, Painting.TO_GALLERY) .select(context);
- Selecting toMany relationship, the result will be as it will be in SQL query
Property<Artist> artist = Property.createSelf(Artist.class); Property<Painting> artistPainting = Artist.PAINTING_ARRAY.flat(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);
Attachments
Issue Links
- is related to
-
CAY-2271 ColumnSelect: support for prefetch and limit
- Closed