/*
  * (non-Javadoc)
  * @see com.csit.dao.CompetitionPhotoDAO#query(com.csit.model.CompetitionPhoto, java.lang.Integer, java.lang.Integer)
  */
 @SuppressWarnings("unchecked")
 @Override
 public List<CompetitionPhoto> query(CompetitionPhoto model, Integer page, Integer rows) {
   Criteria criteria = getCurrentSession().createCriteria(CompetitionPhoto.class);
   if (model != null
       && model.getCompetition() != null
       && model.getCompetition().getCompetitionId() != null) {
     criteria.add(Restrictions.eq("competition", model.getCompetition()));
   }
   if (StringUtils.isNotEmpty(model.getPhotoType())) {
     criteria.add(Restrictions.eq("photoType", model.getPhotoType()));
   }
   criteria.setFirstResult(PageUtil.getPageBegin(page, rows));
   criteria.setMaxResults(rows);
   criteria.addOrder(Order.desc("array"));
   return criteria.list();
 }
 /*
  * (non-Javadoc)
  * @see com.csit.dao.CompetitionPhotoDAO#query(java.lang.Integer, java.lang.String, java.lang.Integer, java.lang.Integer)
  */
 @SuppressWarnings("unchecked")
 @Override
 public List<CompetitionPhoto> query(
     Integer competitionId, String photoType, Integer page, Integer rows) {
   Criteria criteria = getCurrentSession().createCriteria(CompetitionPhoto.class);
   criteria.createAlias("picture", "picture", CriteriaSpecification.LEFT_JOIN);
   if (competitionId != null) {
     criteria.add(Restrictions.eq("competition.competitionId", competitionId));
   }
   if (StringUtils.isNotEmpty(photoType)) {
     criteria.add(Restrictions.eq("photoType", photoType));
   }
   criteria.setFirstResult(PageUtil.getPageBegin(page, rows));
   criteria.setMaxResults(rows);
   criteria.addOrder(Order.asc("array"));
   return criteria.list();
 }
Example #3
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();
  }