JPQL: Select from another select


Trying to script JPQL like in SQL, when you can have a Select … from (Select …)
but seems that this is impossible with JPQL.

Is there any other way to do something like that?
Or it’s possible to group by [calculation logic], like :
group by case when … end, e.colum2,…


Hi Gent,

JPQL doesn’t support calculation logic in the GROUP BY statement.

As a workaround:

  • Rewrite to native SQL
  • Create SQL view, map it to the JPA entity and use JPQL to that entity

Subbotin Andrey