【发布时间】:2012-07-22 16:06:30
【问题描述】:
我在查询中添加了一个投影,它创建了一个类似...的查询
见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_ 表示所有关闭它给出错误的地方。
我将其修改为 Query like ...
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 投影代码
-
引用此链接 --> stackoverflow.com/questions/84644/…
-
感谢@Pradeep,您的链接给了我答案。