I've a little problem with GQL for GoogleAppEngine. If i execute this query on my Datastore:
SELECT * FROM CoursePO ORDER BY createdDate DESC LIMIT 4;
it correctly shows me the response with maximum 4 results (tuple whatever as you want..). When i execute the same query in my Java Code, the result is different. Does anyone know why? I post below the method which does the same Query.
PersistenceManager pm = PMF.get().getPersistenceManager();
Query q = pm.newQuery("SELECT FROM " + CoursePO.class.getName() + " ORDER BY createdDate DESC LIMIT 4");
List<CoursePO> results = (List<CoursePO>)q.execute();
LOGGER.warning("Size: " + results.size()); //This size is greather than 4!! :-(
pm.close();
return results;
Thank you so much in advance
[EDIT] I would like to know, how downVote this question -.- Do you think is a stupid question? Do you think i'm wrong? Try it before judge!
[ADDED INFO] The result content is the same as the simple Query q = pm.newQuery(CoursePO.class); So, all the elements inside the Entity. The only different thing is that the clause ORDER BY DESC works perfectly, but not for LIMIT 4.
[EDIT]
JDOQL doesn't have any LIMIT modifier. Use RANGE instead. Try SELECT FROM ORDER BY createdDate DESC RANGE 0, 10. http://db.apache.org/jdo/jdoql_quickref.pdf