1
我可以讓SQL簡單的查詢在JPQL這樣和它的工作做好:如何從sql查詢獲取jpql查詢?
Query query = em.createQuery("SELECT p2 FROM Zp01 p2 where p2.gestionnaire IN (SELECT d.libelle FROM Affaire d)") ;
liszp01general= (List<Zp01>) query.getResultList();
,但我不能把這種查詢JPQL多數民衆贊成在SQL已經工作:
SELECT p2.* from zp01 p2 join (SELECT TYPEC,count(TYPEC) as cnt_typec FROM planning_cuisson group by TYPEC HAVING COUNT(TYPEC) > 0) p1 where p2.type_cuisson=p1.typec order by cnt_typec asc ;
我想這但沒有工作:
Query query = em.createQuery("SELECT p2 FROM Zp01 p2 join (select G.TYPEC,count(G.TYPEC) as cnt_typec from PlanningCuisson G group by G.TYPEC HAVING COUNT(G.TYPEC) > 0) p1 Where p2.typeCuisson=p1.typec and p2.ordre NOT IN (SELECT k.numof FROM OfSemiplanifie k) AND p2.gestionnaire IN (SELECT d.libelle FROM Affaire d) order by cnt_typec asc");
liszp01general= (List<Zp01>) query.getResultList();
我想這太,但沒有工作'查詢查詢= em.createQuery後
隨着Collections.sort(「SELECT P2從ZP01 P2:所以查詢將成爲沿東西線,(選擇G.TYPEC,通過G.TYPEC HAVING COUNT(G.TYPEC)> 0來計算(G.TYPEC)爲來自PlanningCuisson G組的cnt_typec)p1其中p2.typeCuisson = p1.typec和p2.ordre NOT IN(SELECT k.numof FROM Semiplanifie k)AND p2.gestionnaire IN(SELECT d.libelle FROM Affaire d)order by p1.cnt_typec asc「);' – marouanoviche 2014-09-02 13:53:33