欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

hibernate criteria Restrictions工具类用法

程序员文章站 2022-07-11 11:13:11
CriteriaQuery cq = new CriteriaQuery(TSUser.class, dataGrid); // 查询条件组装器 org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, user) ......

CriteriaQuery cq = new CriteriaQuery(TSUser.class, dataGrid);
// 查询条件组装器
org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(cq, user);
Restrictions.or(Restrictions.ilike("userName", searchValue, MatchMode.ANYWHERE), Restrictions.ilike("realName", searchValue, MatchMode.ANYWHERE));
Restrictions.or(Restrictions.ilike("userOrgList.tsDepart.departname", searchValue, MatchMode.ANYWHERE), Restrictions.ilike("userKey", searchValue, MatchMode.ANYWHERE));
Restrictions.or(Restrictions.ilike("userQuarters", searchValue, MatchMode.ANYWHERE), Restrictions.ilike("userWork", searchValue, MatchMode.ANYWHERE));
cq.add();
this.systemService.getDataGridReturn(cq, true);
TagUtil.datagrid(response, dataGrid);

无限添加or

 List<TSUser> list = criteria.add(Restrictions.or(Restrictions.like("description", key,MatchMode.ANYWHERE),
                             Restrictions.or(Restrictions.like("name", key,MatchMode.ANYWHERE),
                           Restrictions.or(Restrictions.like("direct", key,MatchMode.ANYWHERE),
                           Restrictions.or(Restrictions.like("mainplay",key,MatchMode.ANYWHERE),
                               Restrictions.like("filearea", key,MatchMode.ANYWHERE)))))).list();