I need to pick all pending bookings from next hour till next two hours. I have criteria like this:
calendar.setTime(new Date());
calendar.add(Calendar.HOUR, 1);
cb.and(cb.greaterThanOrEqualTo(bookingRoot.<Date>get("pickupTime"), calendar.getTime()));
calendar.add(Calendar.HOUR, 2);
cq.where(cb.and(cb.equal(bookingRoot.get("status"), CabStatus.PENDING), cb.lessThanOrEqualTo(bookingRoot.<Date>get("pickupTime"), calendar.getTime())));
return getEntityManager().createQuery(cq).getResultList();
But it picks all bookings having pickup time less than than the time after 2 hours. Any help appreciated.