Как написать следующий запрос JDBC в спящем режиме?
Select * from Date_Table where
(START_DT>='2011-05-01 00:00:00.000000' and END_DT<='2011-05-02 00:00:00.000000' )
or
( START_DT<'2011-05-01 00:00:00.000000' and END_DT>='2011-05-01 00:00:00.000000' )
or
( START_DT<'2011-05-02 00:00:00.000000' and END_DT>'2011-05-01 00:00:00.000000' )
order by
START_DT asc
это правильный подход?
Criteria criteria=session.createCriteria(Hours.class);
Criterion one=Restrictions.ge("startDate", startDate);
Criterion two=Restrictions.le("endDate", endDate);
LogicalExpression andOne=Restrictions.and(one, two);
Criterion one_a=Restrictions.lt("startDate", startDate);
Criterion two_a=Restrictions.gt("startDate", startDate);
LogicalExpression andOne_a=Restrictions.and(one_a, two_a);
Criterion one_b=Restrictions.lt("endDate", endDate);
Criterion two_b=Restrictions.gt("endDate", endDate);
LogicalExpression andOne_b=Restrictions.and(one_b, two_b);
LogicalExpression or =Restrictions.or(andOne,andOne_a);
LogicalExpression or1 =Restrictions.or(or,andOne_b);
criteria.add(or1);
criteria.addOrder(Order.desc("startDate"));