[ 
https://issues.apache.org/jira/browse/CAY-2255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nikita Timofeev updated CAY-2255:
---------------------------------
    Fix Version/s: 4.0.M6

> ObjectSelect improvement: columns as full entities
> --------------------------------------------------
>
>                 Key: CAY-2255
>                 URL: https://issues.apache.org/jira/browse/CAY-2255
>             Project: Cayenne
>          Issue Type: Improvement
>          Components: Core Library
>            Reporter: Nikita Timofeev
>            Assignee: Nikita Timofeev
>             Fix For: 4.0.M6
>
>
> *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 factory methods in Property:
> {code}
>     <T extends Persistent> Property<T> createSelf(Class<? super T> type);
>     <T extends Persistent> Property<T> createForRelationship(
>                    Property<?> property, Class<? super T> type)
> {code}
> # Prohibit direct usage of Properties mapped on toMany relationships, so that 
> the following code will throw a {{CayenneRuntimeException}}
> {code}
> List<Object[]> result = ObjectSelect.query(Artist.class)
>         .columns(Artist.ARTIST_NAME, Artist.PAINTING_ARRAY)
>         .select(context);
> {code}
> *Usage examples*:
> # Selecting root object plus some related fields:
> {code}
> 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);
> {code}
> # Selecting toOne relationship:
> {code}
> List<Object[]> result = ObjectSelect.query(Painting.class)
>         .columns(Painting.PAINTING_TITLE, Painting.TO_ARTIST, 
> Painting.TO_GALLERY)
>         .select(context);
> {code}
> # Selecting toMany relationship, the result will be as it will be in SQL query
> {code}
> 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);
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to