Java Criteria表关联查询(两个表未定义关联关系)

        Criteria criteria = this.getSession().createCriteria(Competition.class, "b");
        DetachedCriteria categoryCriteria = DetachedCriteria.forClass(Category.class, "c");
        categoryCriteria.add(Property.forName("c.code").eqProperty("b.subject"));
        categoryCriteria.add(Restrictions.eq("state", true));
        criteria.add(Subqueries.exists(categoryCriteria.setProjection(Projections.property("c.identifier"))));

 

你可能感兴趣的:(Java Criteria表关联查询(两个表未定义关联关系))