我在HQL中爲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
這是給這個錯誤「的檢查倒序」。 如果我刪除它可以正常工作。
任何人都可以請幫我解決這個問題嗎?
謝謝。
你好, 你能證明Hibernate自動生成的這個HQL查詢的SQL(你可以通過show_sql屬性設置爲true使休眠打印)。 從錯誤看來,Hibernate並不像抱怨,但是你的數據庫是。 乾杯 – 2009-06-10 17:50:10