cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucas Holt <l...@foolishgames.com>
Subject Re: Relationship & Sort Ordering
Date Fri, 19 Feb 2010 19:44:22 GMT
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

Mime
View raw message