标签:hibernate
//获取文件和姓名对应关系的信息 <span style="white-space:pre"> </span>public PageBean<NameToLocalFile> getAllNameToLocalFileByPage(Map<String, Object> conditions, int page, int pagesize) { <span style="white-space:pre"> </span>// TODO Auto-generated method stub <span style="white-space:pre"> </span>DetachedCriteria dc = DetachedCriteria.forClass(NameToLocalFile.class); <span style="white-space:pre"> </span>String name = (String) conditions.get("name"); <span style="white-space:pre"> </span>String variety = (String) conditions.get("variety"); <span style="white-space:pre"> </span>String createtime = (String) conditions.get("createtime"); <span style="white-space:pre"> </span>if (StringUtils.isNotBlank(name)) { <span style="white-space:pre"> </span>dc.add(Restrictions.like("name", "%" + name + "%")); <span style="white-space:pre"> </span>} <span style="white-space:pre"> </span>if (null != variety)) { <span style="white-space:pre"> </span>dc.add(Restrictions.eq("variety", variety)); <span style="white-space:pre"> </span>} <span style="white-space:pre"> </span>if(null != createtime){ <span style="white-space:pre"> </span>dc.add(Restrictions.like("createtime", createtime + "%")); <span style="white-space:pre"> </span>} <span style="white-space:pre"> </span>//根据id降序排序 <span style="white-space:pre"> </span>dc.addOrder(Order.desc("id")); <span style="white-space:pre"> </span>@SuppressWarnings("unchecked") <span style="white-space:pre"> </span>PageBean<NameToLocalFile> pageQuery = (PageBean<NameToLocalFile>)super.pageQuery(dc, page, pagesize); <span style="white-space:pre"> </span>return pageQuery; <span style="white-space:pre"> </span>}
标签:hibernate
原文地址:http://blog.csdn.net/u011768325/article/details/46499923