Вопрос

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