Z1. 错误如下
errDetail:org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 9900 near line 1, column 67 [from com.xxx.xxxtable where xxx=xxx and xxx>x order by xx desc];
nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9900 near line 1, column 67 [from com.xxx where xxx=xxx and xxx>x order by xxx desc] errLog:unexpected token: 9900 near line 1, column 67 [from com.xxx where xxx=xxx and xxx>x order by xxx desc]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9900 near line 1, column 67 [from com.xxx where xxx=xxx and xxx>0 order by xxx desc]>>>>>>>org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9900 near lin
W2.debug 发现程序中的sql语句写错了
List<Xxx> a= this.pfind("from Xxx where xx= " + xxx1 + " and xxa>0 order by xxb desc");
其中xx对应数据库中的varchar2类型的字段,xxx1为String类型的变量,观察发现
数据库中的正确语句应该是:
select * from 表名 where xx= ‘xxx1的值’ and xxa>0 order by xxb desc"
比较java文件中的sql与正确的发现少了一对单引号
错误的:"from Xxx where xx= " + xxx1 + " and xxa>0 order by xxb desc"
正确的:"from Xxx where xx= ’" + xxx1 + "‘ and xxa>0 order by xxb desc"
T3.解决办法
添加一对单引号
总结:此类错误一般是hql语句错误。
还有一篇文章也提到了这个问题,感觉不错就拿了它的网址
网址:https://blog.youkuaiyun.com/s_monster_/article/details/78885730