【问题标题】:Complex Ebean Query复杂的 Ebean 查询
【发布时间】:2014-11-12 14:51:09
【问题描述】:

我正在尝试针对这种情况进行 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。 知道怎么做吗?

【问题讨论】:

    标签: java playframework ebean


    【解决方案1】:

    如果last_update_time.plusDays(update_frequency)&lt;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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-12
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 2012-07-13
      • 2012-04-02
      • 2013-05-22
      相关资源
      最近更新 更多