I'm experimenting with App Engine, Datastore and Objectify 4. I have a working Objectify query that fetches all entities of a given kind from the Datastore. I'm trying to sort the result based on a date:
List<MyEntity> entities = OfyService.ofy().load().type(MyEntity.class).order("-createdDate").list();
But after I add order, the query returns 0 records. This is my entity class:
@Entity
public class MyEntity
{
@Id Long id;
Long userID;
@Ignore String username;
@Index String name;
String url;
String description;
@Index Date createdDate;
@Index int viewCount;
}
I've tried to order by other data types with no success. Why does this happen?
-
in theorder()
to return results in ascending order? According to the documentation, App Engine should automatically create an index for Queries with no filters and only one sort order on a property, either ascending or descending. – tx802