2012-08-16 59 views
1

我得到Ebean大部分,但我会怎么做: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')的第二个条件是本来是很容易...

谢谢!

回答

0

如果存在于类座椅,多对多(或一对多)关系到预订,并且如果在预定日期字段的类型是日期,那么这个代码可能是工作:

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()