ordering a selectQuery by ID DESC

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ordering a selectQuery by ID DESC

stefan.leidner

hello,

i try to execute a SelectQuery wich results i want  to be in the descending order according to the ID of my object

DataContext ctx= CayenneMappingFactory.getInstance().getDataContext();
SelectQuery query=new SelectQuery(Referentiel.class);
query.setDistinct(false);
query.addOrdering(new Ordering(Referentiel.ID_REFERENTIEL_PK_COLUMN, Ordering.DESC));
List list=ctx.performQuery(query);

it works perfectly on all attributes but not on the ID_PK

have someone an idea ?

thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ordering a selectQuery by ID DESC

Andrus Adamchik
You may want to try this:

new Ordering("db:" + Referentiel.ID_REFERENTIEL_PK_COLUMN,  
Ordering.DESC)


"db:" prefix tells Cayenne that you are specifying ordering in terms  
of database columns, not object properties.

Andrus

On Aug 1, 2005, at 6:45 PM, [hidden email] wrote:

>
> hello,
>
> i try to execute a SelectQuery wich results i want  to be in the  
> descending order according to the ID of my object
>
> DataContext ctx= CayenneMappingFactory.getInstance().getDataContext();
> SelectQuery query=new SelectQuery(Referentiel.class);
> query.setDistinct(false);
> query.addOrdering(new Ordering
> (Referentiel.ID_REFERENTIEL_PK_COLUMN, Ordering.DESC));
> List list=ctx.performQuery(query);
>
> it works perfectly on all attributes but not on the ID_PK
>
> have someone an idea ?
>
> thanks

Loading...