我在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