hql 错误 unexpected token: (

lij71 2011-03-03 02:52:33
碰见了个问题,求大家帮忙解决

2011-03-03 14:52:00 [STDOUT]-[INFO]-[152] ________hql = from is_static t,(select max(s.st_checkmark) checkmark,s.st_loginid from is_static s where s.st_loginid in (select m.ma_pid from is_machine m where 1=1 ) group by s.st_loginid ) a where t.st_loginid = a.st_loginid and t.st_checkmark = a.checkmark

2011-03-03 14:52:00 [PARSER]-[ERROR]-[33] line 1:18: unexpected token: (

2011-03-03 14:52:00 [WorkConditionManagerCommand]-[INFO]-[1789] java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 18 [from is_static t,(select max(s.st_checkmark) checkmark,s.st_loginid from is_static s where s.st_loginid in (select m.ma_pid from is_machine m where 1=1 ) group by s.st_loginid ) a where t.st_loginid = a.st_loginid and t.st_checkmark = a.checkmark ]

sql里面可以执行,但是这里报"("问题!!
...全文
1656 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuquan2010 2011-09-14
  • 打赏
  • 举报
回复
luweiyuan01 2011-03-04
  • 打赏
  • 举报
回复
hql语句里面表名都是反转实体名以及对应实体属性名称
lij71 2011-03-04
  • 打赏
  • 举报
回复
hql = "select * from emp" ;

Query q = em.createNativeQuery(hql);


这样的语句是可以执行普通的sql语句的,只是得到的是object,而不是实体类

问题处理了,散分!
lij71 2011-03-03
  • 打赏
  • 举报
回复
用的em.createNativeQuery(hql);想用一般的sql语句查的!不行。。。
zl_love_IT 2011-03-03
  • 打赏
  • 举报
回复
hql里from后面跟的是对象名,不是表名。

50,523

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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