我正在尝试针对这种情况进行ebean查询:我想根据用户的last_update_time和update_Frequency(以天为单位)过滤用户,查询应该在 last_update_time.plusDays(update_frequency)<now().
时获取用户
我的查询现在看起来像这样:
List<User> users = Ebean.find(User.class).where().lt("last_update_time",DateTime.now()).findList();
我需要将 update_Frequency 添加到 Last_Update_time 中。 知道怎么做吗?
最佳答案
如果last_update_time.plusDays(update_frequency)<now()
...是有效的 SQL(对于您的数据库)那么您可以通过“原始”表达式将其传递。 query.where().raw(...) 类似:
List<User> users =
Ebean.find(User.class)
.where()
.lt("last_update_time",DateTime.now())
.raw("last_update_time.plusDays(update_frequency)<now()")
.findList()
关于java - 复杂的 Ebean 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26889801/