码迷,mamicode.com
首页 > 其他好文 > 详细

QBC分页查询

时间:2015-07-01 09:54:08      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

public class DetailDaoImpl extends HibernateTemplate implements DetailDaoInterface {

  private Log log=LogFactory.getLog(ConstantsApplication.P2PAPPLICATION_LOG);

/**
 * 查询符合条件的指定区间的记录
 */
 public List<AppInfoPO> queryApproveDetailInfo(ApproveDetailQueryModel qm, int startNumber, int maxNumber) throws APSException {

  log.info("开始查询明细……");
    try{

    DetachedCriteria c = this.getDetachedCriteria(qm);
      return  findByCriteria(c,startNumber,maxNumber);

    } catch (Exception e) {
         log.error("查询明细异常", e);
         throw new APSException("查询明细异常,在方法queryApproveDetailInfo中", e);
     }

}

/**
  * 查询符合条件的记录数
  */
 public int queryApproveDetailInfoCount(ApproveDetailQueryModel qm) throws APSException {

  log.info("开始查询审批明细……");
    DetachedCriteria d = this.getDetachedCriteria(qm);
    d.setProjection(Projections.rowCount());
    List list = this.findByCriteria(d);
    if (list != null && list.size() > 0)
     return Integer.valueOf(list.get(0).toString());
    return 0;

}

/**
 * 创建公共查询条件
 * @param qm
 * @return
 */
 public DetachedCriteria  getDetachedCriteria(ApproveDetailQueryModel qm){
      DetachedCriteria c = DetachedCriteria.forClass(AppInfoPO.class);
          if(!CommonMethod.isNull(qm.getCreditDateisnotnull())){
           c.add(Property.forName("creditDate").isNotNull());
          }

    c.addOrder(Order.asc("creditName"));
      c.addOrder(Order.desc("creditDate")); 
      return c;

}

QBC分页查询

标签:

原文地址:http://www.cnblogs.com/Defry/p/4612362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!