2008年3月23日星期日
相当相当隐蔽的错误 org.hibernate.hql.ast.QuerySyntaxException: unexpected token
今天周末,被头儿过来改bug
其中一个在hql查询的时候报org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ApplyInfo near line 1, column 23这样的错误,貌似看起来hibernate不认识ApplyInfo这个映射持久类,但是这个类非常确定的是已经映射了,而且在别处用的非常正常。郁闷,找啊找
在网上找org.hibernate.hql.ast.QuerySyntaxException: unexpected token的错误有
1、持久类写错了,要不就是写成了数据库表名
2、hibernate3.0不支持select中嵌套查询,据说from中也不行,只支持where中嵌套查询,好像3.1支持了select中嵌套
3、sql语句中字段是用了保留关键字
然后就是我发现的这个隐蔽错误了
发现的from后的空格是一个全角的空格,半角 空格,全角 空格。距离比一样啊,原来就看出from后面的空格大了,还以为是两个空格呢。
隐蔽,太隐蔽了。
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ApplyInfo near line 1, column 23 [SELECT contCount FROM ApplyInfo where applyId = (select applyId from com.capinfo.hibernate.person.pojo.AContinueInfo where id=25)]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at com.capinfo.zgbm.print.dao.PrintQueryDAO.getContinueCount(PrintQueryDAO.java:273)
at com.capinfo.zgbm.print.action.PrintContinueCountAction.execute(PrintContinueCountAction.java:95)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.capinfo.util.LoginFilter.doFilter(LoginFilter.java:61)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at com.capinfo.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:67)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3212)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:1983)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:1890)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1344)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)
Caused by: line 1:23: unexpected token: ApplyInfo
at org.hibernate.hql.antlr.HqlBaseParser.identPrimary(HqlBaseParser.java:4021)
at org.hibernate.hql.antlr.HqlBaseParser.primaryExpression(HqlBaseParser.java:861)
at org.hibernate.hql.antlr.HqlBaseParser.atom(HqlBaseParser.java:3422)
at org.hibernate.hql.antlr.HqlBaseParser.unaryExpression(HqlBaseParser.java:3200)
at org.hibernate.hql.antlr.HqlBaseParser.multiplyExpression(HqlBaseParser.java:3082)
at org.hibernate.hql.antlr.HqlBaseParser.additiveExpression(HqlBaseParser.java:2802)
at org.hibernate.hql.antlr.HqlBaseParser.concatenation(HqlBaseParser.java:570)
at org.hibernate.hql.antlr.HqlBaseParser.relationalExpression(HqlBaseParser.java:2586)
at org.hibernate.hql.antlr.HqlBaseParser.equalityExpression(HqlBaseParser.java:2449)
at org.hibernate.hql.antlr.HqlBaseParser.negatedExpression(HqlBaseParser.java:2413)
at org.hibernate.hql.antlr.HqlBaseParser.logicalAndExpression(HqlBaseParser.java:2331)
at org.hibernate.hql.antlr.HqlBaseParser.logicalOrExpression(HqlBaseParser.java:2296)
at org.hibernate.hql.antlr.HqlBaseParser.expression(HqlBaseParser.java:2082)
at org.hibernate.hql.antlr.HqlBaseParser.aliasedExpression(HqlBaseParser.java:2249)
at org.hibernate.hql.antlr.HqlBaseParser.selectedPropertiesList(HqlBaseParser.java:1455)
at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:1365)
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1106)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238)
... 33 more
订阅:
博文评论 (Atom)
什么高难问题啊
回复删除我顶 一下解决我的问题
回复删除顶,谢谢,拨开云雾见彩虹!找了好久这个错误了!
回复删除不客气 ,哈哈 没想到这个问题 这么多人遇到
回复删除谢谢,我会继续关注你的
回复删除哈哈 果然 我HQL语句掉了个逗号
回复删除不错,分析问题很全面,,,一下就帮到我了,,,
回复删除顶,
回复删除各位,我是jsf新手,我的问题是准备显示一个表中的数据进行查询时出现下面的错,请大家帮忙分析下: com.zyf.xgllwebgis.exception.DbException: unexpected token: * near line 1, column 8 [select * from com.zyf.xgllwebgis.user.Person]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: * near line 1, column 8 [select * from com.zyf.xgllwebgis.user.Person] at com.zyf.xgllwebgis.service.impl.UserServiceHibernateImpl.persons(UserServiceHibernateImpl.java:157) at com.zyf.xgllwebgis.bean.PersonListBean.getPersonList(PersonListBean.java:28)
回复删除回复jxlijsh:去掉 select * 试试
回复删除楼主帮了我 大忙了。这个问题搞晕了我一天。现在我只有两个字表达:晕死。
回复删除update Order order set order.status = :status where order.orderId = :orderId 我的这个哪个地方错 了啊
回复删除org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: order near line 1, column 40 [update com.dingcan.manager.model.Order order set order.status = :status where order.orderId = :orderId]
回复删除order 是关键字吧
回复删除回复dlheart:order 是关键字吧
回复删除