All the sudden my app is now not querying the datastore correctly.
Data is supposed to be order by date desc and as of about 30 minutes
ago it is not working. Anyone know why this stop ordering things
correctly. It still works on my local workstation..
Below is the function I use
private ArrayList<Article> getArticles(int pageNumber, int pageSize)
{
ArrayList<Article> lstArticles = new ArrayList<Article>();
int lowerBound = 0;
int upperBound = pageSize;
if (pageNumber != 0) {
lowerBound = pageNumber * pageSize;
upperBound = lowerBound - pageSize;
}
LOG.log(Level.FINEST,
"ManageArticles.getArticles(int pageNumber, int
pageSize)
upperBound Set at - "
+ Integer.toString(upperBound));
LOG.log(Level.FINEST,
"ManageArticles.getArticles(int pageNumber, int
pageSize)
lowerBound Set at - "
+ Integer.toString(lowerBound));
try {
DatastoreService datastore =
DatastoreServiceFactory.getDatastoreService();
com.google.appengine.api.datastore.Query q = new
com.google.appengine.api.datastore.Query(Article.class.getSimpleName());
PreparedQuery pq = datastore.prepare(q);
q.addSort(Article.pubDatePropName, SortDirection.DESCENDING);
QueryResultList<Entity> results =
pq.asQueryResultList(FetchOptions.Builder.withLimit(pageSize).offset(lowerBound));
for (Entity entity : results) {
lstArticles.add(new Article(entity));
}
} catch (Exception e) {
LOG.log(Level.SEVERE,
"Exception occurred in getArticles(int
pageNumber, int pageSize)
-" +
e.getMessage());
} finally {
//pm.close();
}
return lstArticles;
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.