这是我的数据库(简化):
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);
使用Ebean,我需要列出今年(2012年)没有任何相关部分的所有用户(因此,也包括那些根本没有相关部分的用户)。
但是我看不出我会怎么做:/
我试过了:
User.find.where().isNull("sections").findList(); // but it didn't worked
所以我被困在这里。我该怎么办?
感谢您的帮助! :)
答案 0 :(得分:0)
你需要这样做:
String q="find * fetch sections where sections.id is null"
Ebean.createQuery(User.class,q).findList();
这将创建一个左外连接查询,find.where()。IsNull(“sections”)不起作用。