예제 #1
0
  @Override
  public Long getTotalCount(Reply model) {
    Criteria criteria = getCurrentSession().createCriteria(Reply.class);

    criteria.createAlias("potential", "potential", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias(
        "potentialStuStatus", "potentialStuStatus", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias("user", "user", CriteriaSpecification.LEFT_JOIN);
    if (model != null && model.getPotential().getPotentialId() != null) {
      criteria.add(Restrictions.eq("potential.potentialId", model.getPotential().getPotentialId()));
    }
    if (model != null
        && model.getPotentialStuStatus() != null
        && model.getPotentialStuStatus().getPotentialStuStatusId() != null) {
      criteria.add(
          Restrictions.eq(
              "potentialStuStatus.potentialStuStatusId",
              model.getPotentialStuStatus().getPotentialStuStatusId()));
    }
    if (model != null && model.getReplyDate() != null) {
      criteria.add(Restrictions.eq("replyDate", model.getReplyDate()));
    }
    if (model != null && model.getNextReplyDate() != null) {
      criteria.add(Restrictions.eq("nextReplyDate", model.getNextReplyDate()));
    }
    criteria.setProjection(Projections.rowCount());
    return new Long(criteria.uniqueResult().toString());
  }
예제 #2
0
  @SuppressWarnings("unchecked")
  @Override
  public List<Reply> query(Reply model, Integer page, Integer rows) {
    Criteria criteria = getCurrentSession().createCriteria(Reply.class);

    criteria.createAlias("potential", "potential", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias(
        "potentialStuStatus", "potentialStuStatus", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias("user", "user", CriteriaSpecification.LEFT_JOIN);
    if (model != null && model.getPotential().getPotentialId() != null) {
      criteria.add(Restrictions.eq("potential.potentialId", model.getPotential().getPotentialId()));
    }
    if (model != null
        && model.getPotentialStuStatus() != null
        && model.getPotentialStuStatus().getPotentialStuStatusId() != null) {
      criteria.add(
          Restrictions.eq(
              "potentialStuStatus.potentialStuStatusId",
              model.getPotentialStuStatus().getPotentialStuStatusId()));
    }
    if (model != null && model.getReplyDate() != null) {
      criteria.add(Restrictions.eq("replyDate", model.getReplyDate()));
    }
    if (model != null && model.getNextReplyDate() != null) {
      criteria.add(Restrictions.eq("nextReplyDate", model.getNextReplyDate()));
    }

    if (rows == null || rows < 0) {
      rows = GobelConstants.DEFAULTPAGESIZE;
    }

    criteria.setFirstResult(PageUtil.getPageBegin(page, rows));
    criteria.setMaxResults(rows);

    criteria.addOrder(Order.asc("replyId"));
    return criteria.list();
  }