我当前正在构建查询,我必须使用休眠中的Criteria对象。基本上我的本机查询如下:
select * from HDR where app_no in (select appNo from perm where code in (select code from access where appCode = 'P' and catId in :dymanicParam))
有什么想法如何使用org.hibernate.Criteria构建上述本地查询?
非常感谢您的回复。
答案 0 :(得分:1)
尝试执行此操作
DetachedCriteria accessCriteria = DetachedCriteria.forClass(Access.class)
.setProjection(Property.forName("code"))
.add(Restrictions.eq("appCode", "P"))
.add(Restrictions.eq("catId", dymanicParam));
DetachedCriteria permCriteria = DetachedCriteria.forClass(Perm.class)
.setProjection(Property.forName("appNo"))
.add(Property.forName("code").in(accessCriteria))
DetachedCriteria criteria = DetachedCriteria.forClass(HDR.class)
.add(Property.forName("app_no").in(permCriteria))
// criteria.getExecutableCriteria(session).list();