How do make a query with Entity key and sort it to App Engine datastore in Java?

ownedboy

New Member
I've been programming an app which uses GAE and I store the entities with a specific Key depending on the user nick logged in Google.The problem is that I can't make a query that retrieves the entities with a specific key and sort the entities retrieved by whatever too.I'll give some examples:\[code\]Query query = new Query("Invoice", key);//This works; retrieved all entities that have the keyQuery query = new Query("Invoice").addSort("Date", Query.SortDirection.ASCENDING);//This works too, retrieves ALL entities sorted by the Date field.\[/code\]If I mix them:\[code\]Query query = new Query("Invoice", key).addSort("Date", Query.SortDirection.ASCENDING)://This doesn't work, and it is what I want;to retrieve the entities with the specific key and sorted \[/code\]by a field (doesn't matter right know).Can anybody help me? I've spent all day trying it with no result.
 
Back
Top