`

使用DetachedCriteria分离查询条件

阅读更多

Service
		Criterion c1 = Restrictions.eq("diprojectId", projectId);
		Criterion c2 = Restrictions.in("digroupId", groupId);
		Criterion c3 = Restrictions.eq("divalid", Const_val.C_INT_VALID);
		List<TbDeviceInfo> deviceInfoList = deviceInfoDao.findAvlByProIdAndGroupId(projectId, groupId, c1, c2, c3);


Dao
public List<TbDeviceInfo> findAvlByProIdAndGroupId(Integer projectId, Collection<Integer> groupId, Criterion... c)

		DetachedCriteria criteria = DetachedCriteria.forClass(TbDeviceInfo.class);
		
		for (Criterion criterion : c) {
			criteria.add(criterion);
		}
		List<TbDeviceInfo> results = getHibernateTemplate().findByCriteria(criteria);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics