【问题标题】:Hibernate row value constructorHibernate 行值构造函数
【发布时间】: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


    【解决方案1】:
    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));
    

    【讨论】:

      猜你喜欢
      • 2017-09-02
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 2012-08-07
      相关资源
      最近更新 更多