标签:des blog java io ar div cti log amp
public EmailBean[] findByPage(Date begin, Date end, String emailreference, int pageNo, final int pageSize, String status) throws AIException { List emails = new ArrayList(); try { Session s = getSessionFactory().getCurrentSession(); Criteria hcriteria = s.createCriteria(EmailBean.class); if (begin != null && end != null) { hcriteria.add(Restrictions.between("creation", begin, end)); } if (emailreference != null && !emailreference.isEmpty()) { hcriteria.add(Restrictions.ilike("mailName", emailreference)); } if (status != null && !status.isEmpty()) { hcriteria.createAlias("status", "s"); hcriteria.add(Restrictions.eq("s.statusname", status)); } //Total record number int totalCount = ((Integer) hcriteria.setProjection(Projections.rowCount()).uniqueResult()).intValue(); hcriteria.setProjection( null ); hcriteria.addOrder(Order.desc("creation")).setFirstResult((pageNo - 1)*pageSize).setMaxResults(pageSize); emails = hcriteria.list(); Hibernate.initialize(emails); } catch (Exception e) { _logger.error(e.fillInStackTrace()); throw new AIException("Error when retrieving emails"); } return emails.toArray(new EmailBean[emails.size()]); }
标签:des blog java io ar div cti log amp
原文地址:http://www.cnblogs.com/daijinming/p/3940856.html