Source:
public List<RadiologyOrder> getRadiologyOrders(RadiologyOrderSearchCriteria searchCriteria) { final Criteria crit = sessionFactory.getCurrentSession() .createCriteria(RadiologyOrder.class); if (searchCriteria.getPatient() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.not(Restrictions.eq("voided", true))); } if (searchCriteria.getUrgency() != null) { crit.add(Restrictions.eq("urgency", searchCriteria.getUrgency())); } if (searchCriteria.getFromEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.ge("scheduledDate", searchCriteria.getFromEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE))) .add(Restrictions.ge("dateActivated", searchCriteria.getFromEffectiveStartDate()))); crit.add(disjunction); } if (searchCriteria.getToEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.le("scheduledDate", searchCriteria.getToEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)))) .add(Restrictions.le("dateActivated", searchCriteria.getToEffectiveStartDate()))); crit.add(disjunction); } if (!StringUtils.isBlank(searchCriteria.getAccessionNumber())) { crit.add(Restrictions.eq("accessionNumber", searchCriteria.getAccessionNumber())); } crit.addOrder(Order.asc("accessionNumber")); return crit.list(); }

Target:
public List<RadiologyOrder> getRadiologyOrders(RadiologyOrderSearchCriteria searchCriteria) { final Criteria crit = sessionFactory.getCurrentSession() .createCriteria(RadiologyOrder.class); if (searchCriteria.getPatient() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.not(Restrictions.eq("voided", true))); } if (searchCriteria.getUrgency() != null) { crit.add(Restrictions.eq("urgency", searchCriteria.getUrgency())); } if (searchCriteria.getFromEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.ge("scheduledDate", searchCriteria.getFromEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE))) .add(Restrictions.ge("dateActivated", searchCriteria.getFromEffectiveStartDate()))); crit.add(disjunction); } if (searchCriteria.getToEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.le("scheduledDate", searchCriteria.getToEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)))) .add(Restrictions.le("dateActivated", searchCriteria.getToEffectiveStartDate()))); crit.add(disjunction); } if (StringUtils.isNotBlank(searchCriteria.getAccessionNumber())) { crit.add(Restrictions.eq("accessionNumber", searchCriteria.getAccessionNumber())); } crit.addOrder(Order.asc("accessionNumber")); return crit.list(); }