How to solve “org.hibernate.QueryException: Not all named parameters have been set” error?

后端 未结 4 1252
失恋的感觉
失恋的感觉 2021-01-24 20:38

I am using java-hibernate-mysql combination

When i m doing update query i m getting following error. I don\'t understand what is wrong with hibernate. Following i have

4条回答
  •  天命终不由人
    2021-01-24 21:31

    Are you executing an sql string with the : character in them? If so, Hibernate is expecting a parameter and you're not setting it.

    String sql = "update SomeTable set someColumn = :value";
    

    Using this you would usually set the value parameter using

    SQLQuery query = getSession().createSQLQuery(sql);
    query.setString("value", "Some value with : in it");
    

    or similar. I can only assume your value has a : in it which does not signify a parameter so you should build this as a string and set that as the parameter.

提交回复
热议问题