org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
来源:互联网 发布:并行编程语言 编辑:程序博客网 时间:2024/06/05 15:27
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
sql 语句错误举例:
错误方法:
- @SuppressWarnings("unchecked")
- public List<Member> findMemberByName(String name) {
- List<Member> list = null;
- String queryStr = "from Member mem where mem.name = " + name
- list = (List<Member>) this.getHibernateTemplate().find(queryStr);
- return list;
- }
那么Hibernate在执行这个语句的时候产生的sql语句是:
- select
- .....
- from
- shopping.member member0_
- where
- member0_.loginName=qingyun
错误就在最后一行上 qingyun 没有引号。
修改如下:注意 在生产queryStr 的时候补充了引号
- @SuppressWarnings("unchecked")
- public List<Member> findMemberByName(String name) {
- List<Member> list = null;
- String queryStr = "from Member mem where mem.name = '" + name + "'";
- list = (List<Member>) this.getHibernateTemplate().find(queryStr);
- return list;
- }
产生的正确sql语句如下:
- select
- .....
- from
- shopping.member member0_
- where
- member0_.loginName='qingyun'
ok!
0 0
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exc
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exc
- ssh org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; neste
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exc
- [hibernate]:org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hi
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exce
- org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert:
- org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exceptio
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not get next sequence value
- org.springframework.dao.InvalidDataAccessResourceUsageException
- org.springframework.dao.DataIntegrityViolationException Could not execute JDBC batch update
- acdreamOJ 1108分块算法
- GSM的逻辑信道-业务信道(TCH)
- Find和FirstOrDefault()有什么区别?
- android 源码下载
- cocos2dx A* + tiledMap
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
- define和typedef
- extjs:如何动态修改panel的html属性值
- 【Java.IO】I/O 字符处理流 - 之 - 内存(字符数组)操作流 - CharArrayReader, CharArrayWriter
- python的reduce,lambda,和排序
- SSH整合后console显示sql语句
- 跟我一起走上人生巅峰 迎娶白富美吧
- Accumulation
- MFC 鼠标和键盘