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