Re: Relationship & Sort Ordering

From: Lucas Holt (luk..oolishgames.com)
Date: Fri Feb 19 2010 - 14:44:22 EST

  • Next message: Joe Baldwin: "Re: Relationship & Sort Ordering"

    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 - 14:45:01 EST