ebean 查询,用于匹配不超过 1 个对象



我想有一个查询,给我一个不保存规则的对象列表(例如 id!=10(为此,我可以写这样的东西:

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

现在我想说,给出一个列表,其中 id!=10 && id!=20 && ...为此,一种方法是使用多个.ne,但我不知道我的列表会有多长,

有什么办法可以做到这一点吗?

我使用的是 Play 框架 2.3.4 附带的 Ebean

谢谢

您可以使用以下方法:

/**
* 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();

最新更新