[ https://issues.apache.org/jira/browse/CAY-2669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev updated CAY-2669: --------------------------------- Fix Version/s: 5.0.M1 > Ordering of related entities via relationship definition > -------------------------------------------------------- > > Key: CAY-2669 > URL: https://issues.apache.org/jira/browse/CAY-2669 > Project: Cayenne > Issue Type: Improvement > Components: Core Library, Modeler > Affects Versions: 4.1 > Reporter: Stefan S. > Priority: Major > Fix For: 5.0.M1 > > Attachments: Modeler-FR-Ordering-Property-in-Relationship-Dlg.png > > > +*Current Situation:*+ > 'Details' entities are related to their 'master' entities as specified by > their DB- and object relationships in Cayenne Modeler. When a list of detail > entities is accessed via according methods of the master object, a query is > generated according to the defined relationship and executed to resolve the > details objects. > For example, the generated query for retrieving all PAINTINGS of an artist is > something like: > > {code:java} > SELECT t0.id, t0.name, t0.artist_id, t0.gallery_id FROM PAINTINGS t0 WHERE > t0.artist_id = 999;{code} > > +*Feature Request:*+ > It shall be possible, to optionally define the ordering of the details > entities on DB level (by the query) as attribute of the specific relationship > by one or more properties of the details entity. > Cayenne Modeler shall support this relationship attribute (e.g. as additional > property of the dialog shown below). > > This means, that if no ordering is defined, everything stays as is. > If an ordering is defined, the relationship query of the example above shall > be generated as > > {code:java} > SELECT t0.id, t0.name, t0.artist_id, t0.gallery_id FROM PAINTINGS t0 WHERE > t0.artist_id = 999 ORDER BY t0.name ASC;{code} > > to order the associated paintings by their name. > When additional details objects are attached to the master object on Java > level, the ordering should be maintained, ideally upon the next 'read access' > to the ordered list property since the order is typically not relevant for > persisting the list. > Maintaining the ordering upon modification of the properties relevant for > ordering is not required, but a programmatic way to restore the defined order > on Java level is required. > > +*Benefit:*+ > Convenience: Currently either 'hacks' or separate queries are required to > implement this behavior. A built-in solution, esp. when invloving Cayenne > Modeler, is easier to define and to maintain. > Performance: If not using a separate query it is currently difficult to > figure out when the list need to reordered. Separate, explicit queries are a > significant extra effort for a feature (modelled relationships) that is > 'almost' available and the optimal (as part of object resolution) execution > is again not easy to implement (at least without deep knowledge of Cayenne > internals). The requested feature psuhes sorting of entities onto DB level > (which is typically performant) and is therefore executed only during entity > resolution and (lazyly) upon adding additional details object to the list. -- This message was sent by Atlassian Jira (v8.20.10#820010)