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
The issue is with the part in bold here : 2012-06-08 09:41 (:0)
You should not concatenate String to build your query but instead use parameters. It is the only way to escape the : characters in hql queries.
Example :
String param1 = "neox tty1 2012-06-08 09:40 (:0)\n" +
"neox pts/1 2012-06-08 09:41 (:0)\n"+
"neox pts/0 2012-06-08 09:41 (:0)\n" +
"neox pts/2 2012-06-08 09:41 (:0)\n" +
"neox pts/3 2012-06-08 12:48 (deval-PC.local.lan)\n" +
"[neox@localhost ~]$ ";
String param2 = "2012-06-08 12:48:58";
String id = 43;
String hqlQuery = "update sequence s set s.cmd_output = :cmd_output, " +
"s.cmd_output_time = :cmd_output_time where s.id = :cmdId";
getHibernateTemplate().findByNamedParam(hqlQuery,
new String[] {"cmd_output", "cmd_output_time", "cmdId"},
new Object[] {param1, param2, id});