Most likely you saved the other two entities before you added the @Index annotation. If you want the indexes to be updated, re-save the entities.
List Objectify 4 entities in order (but without filtering)
-
22-06-2023 - |
Question
I am just getting started with Objectify 4 and have defined this class:
@Entity
@Cache
public class Project {
@Id public long id;
@Index public String name;
}
I have saved three such entities and would like to list them sorted by name.
What I observe is the following: if I iterate over ofy().load().type(Project.class).list()
I get all three (but unsorted, obviously), however if I iterate over ofy().load().type(Project.class).order("name").list()
I get only one (apparently the middle one).
What is going on here? How can I list all entities sorted by name (without a filter)? I've noticed that another example uses parent: is this a requirement for this kind of sorting?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow