2015-12-13 101 views
3

我有一个Device类和Event类像这样把条件对列表场在给定的Date fromDate to之间。还有听起来很简单,但我有点不能让我想用Ebean什么,这是我怎么想应该工作,但我得到的设备不正确,使用Ebean和播放框架

Model.Finder<Long, Device> find = new Model.Finder<>(Long.class, Device.class); 
    Page<Device> devicePage = find.where() 
     .or(
      Expr.lt("events.end", from), 
      Expr.gt("events.start", to) 
     ) 
     .orderBy("id asc") 
     .findPagingList(10) 
     .setFetchAhead(false) 
     .getPage(0); 

回答

2
.or(
    Expr.and(
     Expr.lt("events.start", from), 
     Expr.lt("events.end", from) 
    ), 
    Expr.and(
     Expr.gt("events.start", to), 
     Expr.gt("events.end", to) 
    ) 
) 

的理念是:事件的开始&结束日期必须小于FROM日期或必须大于END日期。

+0

很好,这不幸的是不能正常工作 – behzad