2017-04-08 30 views
0

我想要一個查詢,給我一個不包含規則的對象列表(例如id!= 10) 因此,我可以這樣寫:ebean查詢不匹配超過1個對象

new Finder<>(Long.class, Device.class).where().ne("id", 10l).findList(); 

現在我想說的是,給一個列表,其中ID!= 10 & & ID!= 20 & & ...... 實現這一目標,1路是使用多個.ne,但我不知道我的名單可能有多長時間,

有沒有辦法t做到這一點?

我用的是2.3.4

感謝

隨播放框架Ebean

回答

0

您可以使用以下方法:

/** 
* Not In - property has a value in the array of values. 
*/ 
ExpressionList<T> notIn(String propertyName, Object... values); 

/** 
* Not In - property has a value in the collection of values. 
*/ 
ExpressionList<T> notIn(String propertyName, Collection<?> values); 

Ebean.find(Device.class).where().notIn("id", myArrayOfIds).findList(); 

Ebean.find(Device.class).where().notIn("id", myListOfIds).findList();