我终于找到了答案,只需使用两个
roots:
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<POS> cq = cb.createQuery(POS.class); Root<POS> posRoot = cq.from(POS.class); Root<Supplier> supplierRoot = cq.from(Supplier.class); cq.where(cb.and( cb.equal(supplierRoot.get(Supplier_.suppliertId), supplierId), cb.equal(posRoot.get(POS_.posId), posId))); cq.select(posRoot);



