At the moment I am getting the top scores for my Android application from the datastore as follows:
Query query = pm.newQuery(PlayerPersistentData.class);
query.setOrdering("rating desc");
query.setRange(0, 25);
However, I would also like to order the results by the count of a secondary column:
E.g. In normal SQL it would be something like this:
select PlayerPersistentData.*, count(achievements) as achievements_count
from PlayerPersistentData
order by rating desc, achievements_count desc
Achievements is defined in the datastore as follows
@Persistent
private Set<Integer> achievements;
Is this possible using the GAE datastore? And if so how should I create my query?
Thanks in advance
You need to denormalize: store the count as a separate field on your entity, and query on that.