0

Are subqueries in the from clause supported in the latest QueryDSL version? I tried my best but could not find a solution for now.

1 Answers1

1

This is not a QueryDSL issue, but a JPQL limitation. Support for subqueries exists only for Select and Where clauses. From the Hibernate documentation:

Note that HQL subqueries can occur only in the select or where clauses.

You need to use native queries if you wish to utilize subqueries in that fashion. For example, see JPA subquery in from clause for query migration. QueryDSL supports native queries, so the principles should be translatable.

Ido Salomon
  • 205
  • 2
  • 5
  • Thanks for you answer. Native SQL is not a solution for my case as I use various databases for the same query including some db specific time stuff. – Peter Kósa Feb 18 '20 at 11:45
  • I'm not sure what you need, but Querydsl offers different SQL templates. That might work. In any case, it might be better to use a different query. :) If you found the answer helpful, could you please accept it? – Ido Salomon Feb 18 '20 at 14:19