Open abstratt opened 9 years ago
This is a way to rewrite the model above that expresses the grouping explicitly:
static query statePopulationsViaCities() : StatePopulation[*];
begin
return City extent.groupBy((c : City) : State {
c.cityState
}).groupCollect((cities : City[*]) : StatePopulation {
{
abbreviation := cities.one().cityState.abbreviation,
population := cities.sum((c : City) : Integer { c.population })
}
});
end;
(which is supported by the JPQL generator).
In the source model below:
even though there is no explicit grouping, that is what is actually happening, because State.population is a derived property that is modeled as an aggregation.
The generator currently cannot handle that.