我正在尝试为子查询编写一个jpa查询
我正在尝试为子查询编写一个JPQL查询。查询如下我正在尝试为子查询编写一个jpa查询,jpa,jpql,Jpa,Jpql,我正在尝试为子查询编写一个JPQL查询。查询如下 select fos_name, count(ALLOCATION_BUCKET) as bucket_count from (select * from kic.master_mis where ALLOCATION_DATE IN (select max(ALLOCATION_DATE) from
select
fos_name, count(ALLOCATION_BUCKET) as bucket_count
from
(select
*
from
kic.master_mis
where
ALLOCATION_DATE IN (select
max(ALLOCATION_DATE)
from
kic.master_mis
group by BILLED_ID))
where
date(ALLOCATION_DATE) Between 'starting day month -14' AND 'till the date the month completes 30 or 31 days' group by fos_name`
我使用的是MySQL原生查询,但现在有一个可变周期。我使用类型化查询并为内部查询创建列表
TypedQuery<Integer> query1;
query1=getEntityManager().createQuery("select max(m.misId) from MasterMis m group by m.billedId",Integer.class);
List<Integer> distinctRows1=query1.getResultList();
TypedQuery<Object[]> query3;
query3=getEntityManager().createQuery("select m.fosName,count(m.allocationBucket),sum(m.totalOutstanding), count(m.lastDispositionCodeFOS),count(m.totalCollection), sum(m.totalCollection) from MasterMis m where m.misId IN :distinctRows1 "+"and m.allocationBucket like '%B0%' and m.allocationDate BETWEEN :startDate AND :endDate group by m.fosName",Object[].class);
List<Object[]> s1=query3.setParameter("distinctRows1", distinctRows1).setParameter("startDate", startDate, TemporalType.DATE).setParameter("endDate", endDate, TemporalType.DATE).getResultList();
TypedQuery查询1;
query1=getEntityManager().createQuery(“通过m.billedId从MasterMis m组中选择max(m.misId)”,Integer.class);
List distinctRows1=query1.getResultList();
类型查询查询3;
query3=getEntityManager().createQuery(“从MasterMis m中选择m.fosName、count(m.allocationBucket)、sum(m.TotalUnderstanding)、count(m.lastDispositionCodeFOS)、count(m.totalCollection)、sum(m.totalCollection),其中m.misId位于:distinctRows1“+”中,m.allocationBucket类似于“%B0%”,m.allocationDate介于:startDate和:endDate之间,按m.fosName分组”,对象[]。类);
列表s1=query3.setParameter(“distinctRows1”,distinctRows1).setParameter(“startDate”,startDate,TemporalType.DATE).setParameter(“endDate”,endDate,TemporalType.DATE).getResultList();