1

I want to write a JDO query which fetches all objects of Advertisement class and then sort it on the base of time attribute of type long. For fetching all Advertisement objects, i am using following query.

 List<Advertisement> annonces = null;
 Query query = pm.newQuery(Advertisement.class);
 advertisements = (List<Advertisement>) query.execute();

I want to add a filter which should sort result on the base of long property of Advertisement class. Thanks in advance

Piscean
  • 3,069
  • 12
  • 47
  • 96

1 Answers1

2

This Query solved my problem:

 Query query = pm.newQuery(Annonce.class);
 query.setOrdering("timeOfAdvertisement desc");
 annonces = (List<Annonce>) query.execute();
Piscean
  • 3,069
  • 12
  • 47
  • 96