renanleandrof
renanleandrof

Reputation: 6997

QueryDSL: Use a JPASubQuery in JPAQuery.from()

i have an SQL like:

Query 1:

  SELECT
    t.name,
    sum(t.value)
  FROM
    myTable t
  WHERE 
    -- conditions...
  GROUP BY 
    t.name
  HAVING sum(t.value) >= 100

and i have:

Query 2:

  select count(*) from (
   -- QUERY1
) as countQuery

And i'm trying to do it on QueryDSL. I already have my Query 1 as an JPAQuery. Now a need to use it as a subquery, so i'm trying to do something like:

JPASubQuery subQuery = new JPASubQuery(query1.getMetadata());
new JPAQuery().from(subquery).count();

But it's not possible to add a SubQuery in the FROM clause.

It would be a nice feature.

Upvotes: 1

Views: 4600

Answers (1)

renanleandrof
renanleandrof

Reputation: 6997

Ok, it's not possible due to JPA limitations:

https://github.com/querydsl/querydsl/issues/1471

Upvotes: 3

Related Questions