org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query

来源:互联网 发布:c语言编写函数绝对值 编辑:程序博客网 时间:2024/06/05 16:22
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select count(*) as col_0_0_ from NOTICES notices0_ where notices0_.SENDUNIT=北京市药品监督管理局大兴分局机关 order by notices0_.NOTICEDATE desc]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
... (省略一大堆异常信息)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query


-- 错误原因:
1. 原代码: String sql = "from Notices n where n.sendunit = " + sendunit + "order by n.noticedate desc";
2. 现代码: String sql = "from Notices n where n.sendunit ='" + sendunit + "' order by n.noticedate desc";
3. 这个字段是String(varchar2)类型, 没有加上单引号

原创粉丝点击