Nikita Timofeev created CAY-2255:
------------------------------------

             Summary: 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


*Changes in API*:

# Add new Expression {{FullObjectExpression}} 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

*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