Org.springframework.dao.InvalidDataAccessResourceUsageException:could not execute query;
Examples of SQL statement errors:
Error method:
@SuppressWarnings ("unchecked") public list<member> findmemberbyname (String name) {list<member> List = null ; String querystr = "from \ Mem where mem.name =" + Name list = (list<member>) this.gethibernatetemplate (). Find ( QUERYSTR); return list; }
So hibernate the SQL statement that was generated when the statement was executed:
Select ... from Shopping.member member0_ where Member0_.loginname=qingyun
The error Qingyun on the last line without quotes.
The changes are as follows: Note that quotes are added when producing 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; }
The correct SQL statement produced is as follows:
Select ... from Shopping.member member0_ where member0_.loginname= ' Qingyun '
Ok.