ECM
ECM
总版主
总版主
  • 社区居民
  • 忠实会员
  • 原创写手
阅读:1613亚博国际平台老虎机官网:0

HQL Order by query giving problem

楼主#
更多 发布于:2016-05-13 13:27
I have following query written in HQL for Hibernate. ======================================================================== 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
?======================================================================= When above query executes it gives following error: ERROR: column "inspections" does not exist
?It is giving this error for "order by inspections desc". If I remove that it works fine. Can anyone please help me to resolve this problem? Thanks.
answer(解决方案):

I solved it using "order by col_1_0_" in above query.. because hibernate creates column with names col_0_0_, col_1_0_, col_2_0_ and so on.. so if you just need to know the order of your column and add it to order by accordingly.. Thanks. amar4kintu

?

?

?

?

?

?

?

异常中心网是一家专门收集整理程序员编程过程中遇到的常见异常(exception)以及各种异常问答中心的网站。异常中心网旨在,减少程序员在编码遇到异常,处理各种异常时间和痛苦,让程序员能更愉快的、快速的定位异常并查找对应的异常解决方案。异常中心网诚心打造最完美的编程社区为程序员用户服务,努力成为最好的程序员乐园程序员社区程序异常中心程序bug中心异常问答中心

?

喜欢0 评分0
游客

返回顶部