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.
James source share