Пример #1
0
  @Override
  public List<Deal> getOperatorActiveDeals(User user) {
    DetachedCriteria criteria =
        DetachedCriteria.forClass(Deal.class)
            .createAlias("user", "user", CriteriaSpecification.LEFT_JOIN);
    criteria.add(Restrictions.eq("user", user)).add(Restrictions.eq("isEnabled", true));

    DealWorkflowSideType operatorWorkflowSideType =
        workflowDAO.getWorkflowSideType(DealWorkflowSideTypes.OPERATOR_SIDE_ID);

    DealStateType dealCloseState = workflowDAO.getDealStateType(DealStates.CLOSED_ID);

    criteria
        .add(Restrictions.eq("dealWorkflowSideType", operatorWorkflowSideType))
        .add(Restrictions.ne("dealStateType", dealCloseState))
        .add(Restrictions.eq("step", Deal.FINISHED));
    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

    @SuppressWarnings("unchecked")
    List<Deal> deals = hibernateTemplate.findByCriteria(criteria);

    return deals;
  }