Hibernate中in expected错误的原因之一
来源:互联网 发布:找保镖什么软件 编辑:程序博客网 时间:2024/04/30 13:01
今天在执行语句查询时发现怎么都执行不了,换数据库别的表可以执行,以为是数据库表生成时哪里出了问题,一遍又一遍的对映射文件,数据库表,就是没有想出到底哪儿错了,还删了表重新生成表和索引,都没有办法。在网上看了一下资料突然明白,在Spring中没有配置BO。真晕!
出现错误是:
执行查询的时候出了如下错误:
net.sf.hibernate.QueryException: in expected: t [from TbApplyNew t]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:139)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:146)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:133)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:352)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:330)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1368)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:76)
at com.ninetowns.ods.srvvervst.ServiceVersionVisitManager.getVisitSuRecords(ServiceVersionVisitManager.java:79)
at com.ninetowns.ods.srvvervst.ServiceVersionVisitManagerTest.testGetVisitSuRecords(ServiceVersionVisitManagerTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
原因是使用了三层框架:struts+hibernate+spring,在spring配置文件中没有注入hibernate类对应的xml映射文件.
<bean id="hibernateMapping.strongbpm.bpmnew" class="com.strongit.finance.common.util.ListHelper">
<property name="mappings">
<list>
<property name="mappings">
<list>
<!-- 业务表配置文件在此注入 -->
<value>com/strongit/strongbpm/bo/TbApplyNew.hbm.xml</value>
<value>com/strongit/strongbpm/bo/TbApporeNew.hbm.xml</value>
<value>com/strongit/strongbpm/bo/TbApplyNew.hbm.xml</value>
<value>com/strongit/strongbpm/bo/TbApporeNew.hbm.xml</value>
</list>
</property>
</bean>
</property>
</bean>
如果没有使用spring,只是使用了hibernate那么则Hibernate类对应的xml映射文件中的表名和包、类没有修改过来,然后在hibernate.cfg.xml文件中添加对应的记录。
- Hibernate中in expected错误的原因之一。
- Hibernate中in expected错误的原因之一
- XCode中添加第三方库报错Parse Issue: Expected unqualified-id错误的原因
- stray '\241' in program错误的原因
- g++ 编译头class的文件 出现expected unqualified-id before ‘namespace’错误的原因
- IE6,IE7,IE8下报JS错误:expected identifier, string or number的原因及解决办法
- IE6,IE7,IE8下报JS错误:expected identifier, string or number的原因及解决办法
- python中IndentationError: expected an indented block错误的解决方法
- ORA-00214错误原因之一
- mysql 1067 错误原因(之一)
- XP出现"内存不能read "的错误原因之一
- 死递归:“段错误”产生的可能原因之一
- 单片机Can总线通信出现错误的原因分析之一
- 关于ORACLE可能引起数字类型错误的原因之一
- Hessain调用expected end of map ('z') at '?'错误原因
- hibernate.cfg.xml报错原因之一
- hibernate常见错误及原因
- hibernate中出现的错误
- Response.Redirect发生线程终止,解决后做个总结
- 30分钟正则表达式指导2
- struts2+Spring2.0+Hibernate3使用注解的登录验证
- 从右下角出来的广告实例_js代码
- 从右下角出来的广告实例
- Hibernate中in expected错误的原因之一
- 能走的年月日
- 架构设计(三)——安全性设计
- 弹出窗口
- ASP.NET程序中常用的三十三种代码
- windows IE 浏览器的故障整理
- 页面缓存
- ComponentOne FlexGrid for _NET (2_0) Help
- Java线程总结