大家帮忙看看,这条HQL语句错在哪?

Xunxinqiujiao 2005-09-08 05:47:05
"select cl.szcontainerCode as clcode,el.lenterId as eldt from ContainerLog as cl,EnterLeaveLog as el where cl.enterLeaveLog.lenterId=el.lenterId"
结果出错,excpetion:
org.springframework.orm.hibernate.HibernateQueryException: , expected in SELECT [select cl.szcontainerCode as clcode, el.lenterId as eldt from com.cenin.depot.hibernate.ContainerLog as cl,com.cenin.depot.hibernate.EnterLeaveLog as el where cl.enterLeaveLog.lenterId=el.lenterId];
nested exception is net.sf.hibernate.QueryException: , expected in SELECT [select cl.szcontainerCode as clcode, el.lenterId as eldt from com.cenin.depot.hibernate.ContainerLog as cl,com.cenin.depot.hibernate.EnterLeaveLog as el where cl.enterLeaveLog.lenterId=el.lenterId]
所是少","? 可是明明有","呀,如果把上面select中的前两个as去掉,变成下这样:

"select cl.szcontainerCode, el.lenterId from ContainerLog as cl,EnterLeaveLog as el where cl.enterLeaveLog.lenterId=el.lenterId"

就没问题了,但是得到的Object里没有字段名,用起来不方便....

请大家帮忙看看,这问题出在哪里呢,谢谢~~!
...全文
154 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shiwaxingge 2005-09-10
  • 打赏
  • 举报
回复
select cl.szcontainerCode as clcode,el.lenterId as eldt from ContainerLog as cl,EnterLeaveLog as el where cl.enterLeaveLog.lenterId=el.lenterId
-----------------------------------------------------------------------
select cl.szcontainerCode as clcode,el.lenterId as eldt from ContainerLog as cl,EnterLeaveLog as el where cl.lenterId=eldt
Xunxinqiujiao 2005-09-09
  • 打赏
  • 举报
回复
只去掉as会报一样的错误,55
我看有些HQL的例子里面可以给表的字段起别名,但是为啥我这个就不行呢?
zling1981 2005-09-08
  • 打赏
  • 举报
回复
表的字段就不要再用别名表示了。
不争馒头 2005-09-08
  • 打赏
  • 举报
回复
只去掉as试试看

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧