2

使用 PlayFramework,我试图列出没有与我的模型关联的 ManyToMany 项目的所有项目,我该怎么做?

这是我的结构:

User
    @ManyToMany
    List<Section> sections;

    public static Model.Finder<Long,User> find = new Model.Finder<Long, User>(Long.class, User.class);

Section
    Integer year;
    @ManyToMany
    List<User> users;

    public static Model.Finder<Long,Section> find = new Model.Finder<Long, Section>(Long.class, Section.class);
4

2 回答 2

4

你需要这样做:

String q="find * fetch sections where sections.id is null"

Ebean.createQuery(User.class,q).findList();

这将创建一个左外连接查询, find.where().IsNull("sections") 不起作用。

于 2013-06-14T18:45:24.613 回答
2

试试这些:

find.where().eq("sections", null).findList();

或者

find.where().isNull("sections").findList();

抱歉,这是我的想法,现在无法验证。

于 2012-12-10T11:10:14.747 回答