Added to tracker: http://jira.springframework.org/browse/ROO-241
I'd be happy enough with either solution you suggest. Using the finder name would be more flexible (since a user could create a new finder with a different order clause), but a "default" case would handle most of the use cases I've come across.
Even more flexible would be to allow the 'order by" clause to be passed in to the finder method (perhaps via some kind of "OrderClause" object). But I suspect that may not be desirable on your end.
Btw, there are a couple of related enhancements that would give developers more control over sort order in queries.
1) Allow the use of "lists" (instead of sets) when creating new fields on objects
2) Add optional "-OrderBy" on the list generated in #1
I.e., I want to do this:
Code:
add field list -class ~.domain.Employee -fieldName tasks -element ~.domain.Task -mappedBy employee -orderBy ~.domain.Task.description
to get this:
Code:
public class Vet
{
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "employee")
@javax.persistence.OrderBy("description ASC")
private List<Task> specialties = new ArrayList<Task>();
}
(I'd be happy to add these to the issue or put in a separate feature request if you think these are appropriate ideas.)