1

I have the following SQL query:

select count(*) from (
    select *, count(*)  
    from po_item 
    where sku_code ="SKU_TEST_4" and allocated = false and wip = false 
    group by warehouse
) as t

I was able to write the following inner query with Criteria API and JPQL

select *, count(*)
from po_item 
where sku_code ="SKU_TEST_4" and allocated = false and wip = false
group by warehouse

but couldn't write it along with the outer part. How to do it with JPQL or Criteria API?

wypieprz
  • 7,981
  • 4
  • 43
  • 46
Ysak
  • 2,601
  • 6
  • 29
  • 53
  • 1
    Could you post the queries you have tried and expected and actual outputs. Probability it helps others to understand and arrive to answer easier – WoodChopper Nov 28 '15 at 06:34
  • My requirement is pretty simple. How to do query "select count(*) from (select *, count(*) from po_item where sku_code ="SKU_TEST_4" and allocated = false and wip = false group by warehouse) as t" using JPA Criteria or JPQL – Ysak Nov 28 '15 at 09:19
  • You cannot create subqueries in `FROM` clause with JPQL: http://stackoverflow.com/a/7291855/2387977 – Dherik Dec 11 '15 at 00:16
  • I think then I got ****ed with JPQL...because my entire project is running with JPQL.....What is the best alternative to do this other than using native queries – Ysak Dec 11 '15 at 05:30

0 Answers0