Hibernate の HQL で記述された次のクエリがあります。
================================================== ======================
select new map(ret.retailerDesc as ret_name, ret.id.retailerId as ret_id,
ret.id.serviceId as service_id,
(select count(distinct i.inspectionId) as inspections from Inspection i
inner join i.clgCodeStatus c
inner join c.retailerOrderses r
inner join r.cusRetailer cr
inner join i.inspectionMission m where ret.id = cr.id ) as inspections ,
(select count(distinct i.inspectionId) as inspections from Inspection i
inner join i.clgCodeStatus c
inner join c.retailerOrderses r
inner join r.cusRetailer cr
inner join i.inspectionMission m
where ret.id = cr.id and i.inspectionResult = '1' ) as match,
(select count(distinct i.inspectionId) as inspections from Inspection i
inner join i.clgCodeStatus c
inner join c.retailerOrderses r
inner join r.cusRetailer cr
inner join i.inspectionMission m
where ret.id = cr.id and i.inspectionResult = '0' ) as mismatch )
from CusRetailer ret order by inspections desc
================================================== =====================
上記のクエリを実行すると、次のエラーが発生します。
ERROR: column "inspections" does not exist
「注文による検査の説明」でこのエラーが発生しています。それを削除すると、正常に動作します。
誰でもこの問題を解決するのを手伝ってもらえますか?
ありがとう。