SQLGrammarException: could not execute query

前端 未结 2 1278
醉话见心
醉话见心 2021-01-05 14:56

I am using Struts2 & Hibernate and getting below error when I searched data with string test but works for me when I searched with numeric 111.

2条回答
  •  既然无缘
    2021-01-05 15:34

    Your hql to sql converted query is generating:

        "where employeeName=Name" 
    

    while it should be generating:

        "where employeeName='Name'".
    

    So your hql should be :

        "where b.employeeName= ' " +empName+ " ' "; 
    

    Note : You don't need to do that for integer values, only applies to String variables.

提交回复
热议问题