I'm following How can I sort related entities in Ebean? but i got this error
RuntimeException: Can not find Master [class models.Card]
in Child[models.FinalMark]
Is the solution forgot to put this? Even with ID stil not working.
@Id
public Integer id;
I think my case quite similar.
@Entity
public class Club extends Model {
@Id
public Long id;
public String name;
@OneToMany(cascade = CascadeType.ALL)
@OrderBy("name asc")
public List<Male> male = new ArrayList<>();
@OneToMany(cascade = CascadeType.ALL)
@OrderBy("name asc")
public List<Female> female = new ArrayList<>();
private static Finder<Long, Club> find =
new Finder<>(Long.class, Club.class);
}
@Entity
public class Male extends Model {
@Id
public Long id;
public String name;
private static Finder<Long, Male> find = new Finder<>(Long.class, Male.class);
}
@Entity
public class Female extends Model {
@Id
public Long id;
@ManyToOne
public Club club;
public String name;
private static Finder<Long, Female> find = new Finder<>(Long.class, Female.class);
}
I've intial data
male:
- !!models.Male &m1
name: "Martin"
- !!models.Male &m2
name: "Alan"
female:
- !!models.Female &f1
name: "June"
- !!models.Female &f2
name: "Babe"
club:
- !!models.Club
name: "BigClub"
male:
- *m1
- *m2
female:
- *f1
- *f2
during initialization.
Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml
.load("initial-data.yml");
// Insert club
Ebean.save(all.get("club"));
when i call Club.find.all(), the male and female fields still not sort in ascending. I've tried 2 different ways (each in male & female). both also not sort in asc. any idea?