/*
  * (non-Javadoc)
  * @see com.csit.dao.CompetitionPhotoDAO#getTotalCount(com.csit.model.CompetitionPhoto)
  */
 @Override
 public Long getTotalCount(CompetitionPhoto model) {
   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.setProjection(Projections.rowCount());
   return new Long(criteria.uniqueResult().toString());
 }
 /*
  * (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();
 }