0
我在查詢中添加投影,它創造了一個查詢像...HQL投影創建一個問題
見link
select
this_.TEMPLATE_ID as y0_,
this_.TEMPLATE_NAME as y1_,
this_.CREATE_DATE as y2_,
this_.UPDATE_DATE as y3_,
this_.STATUS_CODE as y4_,
this_.USER_ID as y5_,
this_.UPDATED_BY as y6_,
this_.CATEGORY_ID as y7_,
this_.PRACTICE_ID as y8_
from
templates this_
inner join
user user1_
on this_.USER_ID=user1_.USER_ID
inner join
template_categories category2_
on this_.CATEGORY_ID=category2_.CATEGORY_ID
where
y4_=?
and y8_=?
and y5_ in (
?, ?
)
order by
y1_ asc limit ?
而現在的問題是一樣.. Unknown column 'y4_' in 'where clause'
和y8_同樣的錯誤,y5_表示所有的地方在接近時發出錯誤。
我修改它來查詢像...
select
this_.TEMPLATE_ID as y0_,
this_.TEMPLATE_NAME as y1_,
this_.CREATE_DATE as y2_,
this_.UPDATE_DATE as y3_,
this_.STATUS_CODE as y4_,
this_.USER_ID as y5_,
this_.UPDATED_BY as y6_,
this_.CATEGORY_ID as y7_,
this_.PRACTICE_ID as y8_
from
templates this_
inner join
user user1_
on this_.USER_ID=user1_.USER_ID
inner join
template_categories category2_
on this_.CATEGORY_ID=category2_.CATEGORY_ID
where
this_.STATUS_CODE=1
and this_.PRACTICE_ID=1
and this_.USER_ID in (
1, 2
)
order by
y1_ asc limit ?
和它的工作。但我不知道如何在HQL中修改它?
投影提供您的具體Java代碼 – NPKR 2012-07-24 10:50:51
reffer此鏈接 - > http://stackoverflow.com/questions/84644/hibernate-query-by-example-and -projections – NPKR 2012-07-24 10:59:15
感謝@Pradeep你的鏈接給了我答案。 – Ketan 2012-07-24 12:58:24