0

我正在学习 JPQL,我想知道如何将此查询转换为 JPQL ?

我有Astreastres 表和Planeteplanetes 表的实体。generate_series()是 PostgreSQL 函数。

SELECT t1.galaxie, t1.ss, t1.position FROM 
(
   SELECT galaxie, ss, position FROM 
   generate_series(1, 9) galaxie 
   CROSS JOIN generate_series(1, 500) ss 
   CROSS JOIN generate_series(1, 15) position 
) t1
 LEFT JOIN 
(
   SELECT a.galaxie, a.ss FROM astres a 
   INNER JOIN planetes p 
   ON a.id=p.astre_id 
   WHERE p.planete_mere=TRUE 
   GROUP BY a.galaxie, a.ss 
   HAVING COUNT(*)=3 
) t2 
ON t1.galaxie = t2.galaxie 
AND t1.ss = t2.ss 
LEFT JOIN 
( 
   SELECT a.galaxie, a.ss, a.position FROM astres a 
   INNER JOIN planetes p 
   ON a.id=p.astre_id 
) t3 
ON t1.galaxie=t3.galaxie 
AND t1.ss=t3.ss 
AND t1.position=t3.position 
WHERE t2.galaxie IS NULL 
AND t3.galaxie IS NULL 
ORDER BY t1.galaxie, t1.ss, t1.position

如果需要,我可以提供实体代码。

感谢帮助。

4

0 回答 0