Phai Vv
Phai Vv

Reputation: 1

Are there any way to create query from sql query to entity object query in jpa

I have a query like the one shown below:

SELECT
  SUM (LIMIT_AMOUNT)
FROM
  (SELECT
    CTR_NO
    , REPORT_DATE
    , LIMIT_AMOUNT
    , ROW_NUMBER()
  OVER (PARTITION BY CTR_NO, REPORT_DATE ORDER BY REPORT_DATE) rn
  FROM LOD_CONTRACT
  WHERE
    br_cst_code='3432434'
  AND REPORT_DATE BETWEEN '20-FEB-15' AND '28-FEB-15') b
WHERE
  b.rn=1;

How can I build a SQL query for a JPA-managed entity like:

SELECT
  SUM (o.limit_amount)
FROM
  (SELECT
    o.ctr_no
    , o.rpt_dt
    , o.limit_amount
    , ROW_NUMBER()
  OVER (PARTITION BY o.ctr_no, o.rpt_dt ORDER BY o.rpt_dt) rn
  FROM LOD_CONTRACT o
  WHERE
    o.br_cst_code='3432434'
  AND o.rpt_dt BETWEEN '20-FEB-15' AND '28-FEB-15') b
WHERE
  b.rn=1;

Upvotes: 0

Views: 114

Answers (1)

Tea Curran
Tea Curran

Reputation: 2983

JPQL doesn't currently support Oracle partition tables. To use this feature you will have to stick to Native queries.

Upvotes: 1

Related Questions