【发布时间】:2015-10-15 05:45:54
【问题描述】:
有谁知道如何将此 HQL 片段的 where 条件转换为 CriteriaQuery?
from Cat as cat
where not ( cat.name, cat.color ) in (
select cat.name, cat.color from DomesticCat cat
)
【问题讨论】:
标签: hibernate jakarta-ee jpa hql
有谁知道如何将此 HQL 片段的 where 条件转换为 CriteriaQuery?
from Cat as cat
where not ( cat.name, cat.color ) in (
select cat.name, cat.color from DomesticCat cat
)
【问题讨论】:
标签: hibernate jakarta-ee jpa hql
Criteria criteria = session.createCriteria(Cat.class, "c");
DetachedCriteria subquery = DetachedCriteria.forClass(DomesticCat.class, "dc");
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.property("dc.name"));
projectionList.add(Projections.property("dc.color"));
subquery.setProjection(projectionList);
criteria.add(Subqueries.propertiesNotIn(new String[] { "c.name", "c.color" }, subquery));
【讨论】: