【问题标题】:Ebean complex joinEbean复杂连接
【发布时间】:2012-08-16 19:12:16
【问题描述】:

大部分情况下我都获得了 Ebean,但我将如何做到这一点:

select s.id, s.name, s.city, b.date
from seat s
left join booking b on (s.id = b.listing_id)
  and b.date >= '2011-09-05'

如果不是因为加入的第二个条件 (and b.date >= '2011-09-05'),它会很容易...

谢谢!

【问题讨论】:

    标签: playframework playframework-2.0 ebean


    【解决方案1】:

    如果存在于类 Seat、与 Booking 的多对多(或 OneToMany)关系,并且如果 Booking 中的字段日期为 Date 类型,则此代码可能有效:

    Finder<XXX, Booking> finder = new Finder<>(XXX.class, Booking.class);
    DateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd");
    FIND
       .fetch("seat")
       .where()
       .ge("date", dateFormat.parse("2011-09-05"))
       .findList()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多