How can I join a subquery in JPQL

I need JPQL to query MySQL:

SELECT * FROM table1 t1 INNER JOIN table2 t2 ON t1.id = t2.table1.id INNER JOIN (SELECT * FROM table1 t3 INNER JOIN table2 t4 ON t3.id = t4.table1.id WHERE t3.name = 'xxx') subTable ON t1.number = subTable.number WHERE t1.number = '5' AND id = '3' 
+4
source share
1 answer

Your query seems rather pathological, perhaps tell me what result you are trying to query, and indicate your object model.

In general, JPQL does not support subselects in the from clause, so your query is not directly converted to JPQL.

You can always simply execute it as a native JPA SQL query, since you seem to like SQL than JPQL.

+2
source

Source: https://habr.com/ru/post/1403878/


All Articles