org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 89 near line 1, column 72
[update com.lansone.btrankline.entity.Users u set u.userCardnum = 00000089 where u.userMobilephone = 13906110017]
传入的参数为00000089 时,报这个错误,就是参数不能以0开头,
传入不以0为开头的数字是正确执行的
修改SQL语句如下
String hql="update Users u set u.userCardnum = to_char('"+newCard+"') where u.userMobilephone = "+userMobilephone;
或者
String hql="update Users u set u.userCardnum = :newCard where u.userMobilephone = :userMobilephone";
-------
[update com.lansone.btrankline.entity.Users u set u.userCardnum = 00000089 where u.userMobilephone = 13906110017]
传入的参数为00000089 时,报这个错误,就是参数不能以0开头,
传入不以0为开头的数字是正确执行的
修改SQL语句如下
String hql="update Users u set u.userCardnum = to_char('"+newCard+"') where u.userMobilephone = "+userMobilephone;
或者
String hql="update Users u set u.userCardnum = :newCard where u.userMobilephone = :userMobilephone";
-------
本文探讨了在使用Hibernate框架执行更新操作时遇到的QuerySyntaxException异常问题,并提供了两种有效的解决方案来避免参数以0开头导致的语法错误。
1364

被折叠的 条评论
为什么被折叠?



