Lucas,
It looks like your example is the standard way to perform sort-ordering on a SelectQuery.
In the scenario I am working on, I have a CayenneDataObject that has a to-many relationship that the obj returns as a list. The list is created as the result of what I presume is some sort of SelectQuery auto-generated by Cayenne.
Currently I am doing "in-memory sorting of lists" described in the "Using Orderings" section of the Cayenne Guide.
This is working quite well, but I realized that the toMany list should be sorted in all cases. Therefore I was wondering if Cayenne has a way to modify what I assume is the auto-generated SelectQuery associated with the relationship so that it can be applied in all cases.
Thanks,
Joe
On Feb 19, 2010, at 2:44 PM, Lucas Holt wrote:
> Joe Baldwin wrote:
>> I need to sort-order a list returned from a to-many relationship. It is logical that this ordering be applied in all cases.
>>
>> Question:
>> Is there a simple way to apply this by modifying the SelectQuery associated with the relationship or should I just sort order the list each time it is returned?
>>
>> (If I missed it in the docs please send me a link.)
>>
>> Thanks,
>> Joe
>>
>>
>
> Look at the documentation on "orderings". For cayenne 3,
>
> final SelectQuery query = new SelectQuery( Company.class );
> query.setPageSize( 50 );
> query.addOrdering( "companyName", SortOrder.ASCENDING );
> final List<Company> c = dataContext.performQuery( query );
>
> Lucas
This archive was generated by hypermail 2.0.0 : Fri Feb 19 2010 - 15:18:44 EST