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

DetachedCriteria使用记录

时间:2015-06-15 11:23:40      阅读:140      评论:0      收藏:0      [点我收藏+]

标签: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>}

DetachedCriteria使用记录

标签:hibernate

原文地址:http://blog.csdn.net/u011768325/article/details/46499923

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