标签:
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;
}
标签:
原文地址:http://www.cnblogs.com/Defry/p/4612362.html