-2

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

「注文による検査の説明」でこのエラーが発生しています。それを削除すると、正常に動作します。

誰でもこの問題を解決するのを手伝ってもらえますか?

ありがとう。

4

2 に答える 2

2

式を繰り返す必要がある場合があるかもしれませんinspections

...from CusRetailer ret order by count(distinct i.inspectionId)

HQL がorder by句の式をサポートしていない可能性があります。代わりに SQL クエリを使用する必要がある場合があります。

于 2009-06-09T06:38:14.850 に答える
0

上記のクエリで「order by col_1_0_」を使用して解決しました..休止状態がcol_0_0_、col_1_0_、col_2_0_などの名前の列を作成するため..列の順序を知り、それに応じてorder byに追加する必要がある場合。 .

ありがとう。

amar4kintu

于 2009-12-29T12:06:27.770 に答える