2012-12-06 36 views
1

這裏是我的數據庫(簡化):發現有許多許多的相關空或條件不匹配

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( 「節」)不起作用。