Source:
<code>public List<Order> getOrders(OrderSearchCriteria searchCriteria) { Criteria crit = sessionFactory.getCurrentSession().createCriteria(Order.class); if (searchCriteria.getPatient() != null && searchCriteria.getPatient().getPatientId() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (searchCriteria.getCareSetting() != null && searchCriteria.getCareSetting().getId() != null) { crit.add(Restrictions.eq("careSetting", searchCriteria.getCareSetting())); } if (searchCriteria.getConcepts() != null && !searchCriteria.getConcepts().isEmpty()) { crit.add(Restrictions.in("concept", searchCriteria.getConcepts())); } if (searchCriteria.getOrderTypes() != null && !searchCriteria.getOrderTypes().isEmpty()) { crit.add(Restrictions.in("orderType", searchCriteria.getOrderTypes())); } if (searchCriteria.getActivatedOnOrBeforeDate() != null) { <START> crit.add(Restrictions.le("dateActivated", searchCriteria.getActivatedOnOrBeforeDate())); <END> } if (searchCriteria.getActivatedOnOrAfterDate() != null) { crit.add(Restrictions.ge("dateActivated", searchCriteria.getActivatedOnOrAfterDate())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.eq("voided", false)); } crit.addOrder(org.hibernate.criterion.Order.desc("dateActivated")); return crit.list(); }</code><technical_language>I this now, called "getActivateOnOrBeforeDate", interpreting this a Date (without a time component) a Java Data includes time component. For instance, if Order activated "2018-02-01 15:52:50", in search criteria passed in "2018-02-01 00:00:00", I expect order returned, I query is written currently wouldn't? solution in this query change time component of getActivatedOnOrBeforeDate variable millisecond of current date. for getActivatedOnOrAfterDate set time component 00:00:00</technical_language>

Target:
public List<Order> getOrders(OrderSearchCriteria searchCriteria) { Criteria crit = sessionFactory.getCurrentSession().createCriteria(Order.class); if (searchCriteria.getPatient() != null && searchCriteria.getPatient().getPatientId() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (searchCriteria.getCareSetting() != null && searchCriteria.getCareSetting().getId() != null) { crit.add(Restrictions.eq("careSetting", searchCriteria.getCareSetting())); } if (searchCriteria.getConcepts() != null && !searchCriteria.getConcepts().isEmpty()) { crit.add(Restrictions.in("concept", searchCriteria.getConcepts())); } if (searchCriteria.getOrderTypes() != null && !searchCriteria.getOrderTypes().isEmpty()) { crit.add(Restrictions.in("orderType", searchCriteria.getOrderTypes())); } if (searchCriteria.getActivatedOnOrBeforeDate() != null) { Calendar cal = Calendar.getInstance(); cal.setTime(searchCriteria.getActivatedOnOrBeforeDate()); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); crit.add(Restrictions.le("dateActivated", cal.getTime())); } if (searchCriteria.getActivatedOnOrAfterDate() != null) { Calendar cal = Calendar.getInstance(); cal.setTime(searchCriteria.getActivatedOnOrAfterDate()); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); crit.add(Restrictions.ge("dateActivated", cal.getTime())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.eq("voided", false)); } crit.addOrder(org.hibernate.criterion.Order.desc("dateActivated")); return crit.list(); }