2013-06-24 26 views
0

我想在Play Framework 2.1中使用Ebean搜索項目,使用Finder並找到符合條件的而不是。某種left join a_table t ... where t.id is null(或者可能是where not exists)。Ebean Finder:找到不符合條件的項目

我找不到如何通過閱讀Ebean的API。谷歌也沒有幫助。

是否可以做到這一點? 如果是,如何?

舉一個例子,假設我有一些有訂閱年份的人。我想檢索沒有當前訂閱的人員。

public class Person { 
    @OneToMany(mappedBy = "person", cascade = CascadeType.ALL) 
    public List<Subscription> subscriptions; 
} 

謝謝!

阿爾

回答

0

我終於用com.avaje.ebean.Query

在我的例子:

String q = "find * fetch subscriptions " 
     + "where subscriptions.startDate > :today " 
     + " or subscriptions.endDate < :today " 
     + " or subscriptions.id is null"; 
Query<Person> query = Ebean.createQuery(Person.class, q); 
query.setParameter("today", LocalDate.now()); 
return query.findList(); 

它似乎工作。

相關問題