[eStore]2011-12-15 13:47:21,890 ERROR Probably an exception caught by Spring MVC, check the debug info which may help identifying the error. | reportError_jsp._jspService(121)
[eStore]2011-12-15 13:47:21,890 ERROR Detailed JSP Exception: | reportError_jsp._jspService(125)
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2216)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.SQLException: ORA-01722: 鏃犳晥鏁板瓧
经过多次测试发现:
String hql="from Customer t where t.telephone='"+tel+"'";//可以
String hql="from Customer t where t.telephone="+tel;//报错
查原因:估计是oracle会将变化一下where to_numer( t.telephone)。
所以出现以上错误,转化一下试试
本文探讨了在使用Spring MVC框架时遇到的一个关于Hibernate与Oracle数据库的异常问题,具体为在进行特定查询时出现的SQLGrammarException。通过深入分析,作者发现问题是由于在构建HQL查询字符串时,对于变量的处理方式导致了Oracle的解析错误。文章提供了修改后的代码实现,解决了这一问题,并解释了Oracle可能的解析方式,有助于理解在不同数据库环境下构建SQL查询时的注意事项。
3442

被折叠的 条评论
为什么被折叠?



