Org. springframework. Dao. invaliddataaccessresourceusageexception: cocould not execute query;
SQL statement error example:
Error Method:
@ Suppresswarnings ("unchecked") <br/> public list <member> findmemberbyname (string name) {</P> <p> List <member> List = NULL; </P> <p> string querystr = "from member mem where mem. name = "+ name </P> <p> List = (list <member>) This. gethibernatetemplate (). find (querystr); </P> <p> return list; <br/>}
The SQL statement that hibernate generates when executing this statement is:
Select <br/>... <br/> from <br/> shopping. Member member0 _ <br/> where <br/> member0 _. loginname = Qingyun
The error is that Qingyun has no quotation marks on the last line.
Modify as follows: note that quotation marks are added when querystr is produced.
@ Suppresswarnings ("unchecked") <br/> public list <member> findmemberbyname (string name) {</P> <p> List <member> List = NULL; </P> <p> string querystr = "from member mem where mem. name = '"+ name +"' "; </P> <p> List = (list <member>) This. gethibernatetemplate (). find (querystr); </P> <p> return list; <br/>}
The correct SQL statement is as follows:
Select <br/> ..... <br/> from <br/> shopping. member member0 _ <br/> where <br/> member0 _. loginname = 'qingyun'
OK!