문제

In SQL, we can check the date overlaps as

SELECT (DATE '2001-02-16', DATE '2001-12-21') OVERLAPS
   (DATE '2001-10-30', DATE '2002-10-30');

How can we imitate the same using hibernate Restrictions ?

도움이 되었습니까?

해결책

Use:

 criteria.add(Restrictions.ge("endDate", startDate2));
 criteria.add(Restrictions.le("startDate", endDate2));

Where:

startDate and endDate are your entity's dates.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top