我正在使用Hibernate,我想进行批量更新,更改ids列表中所有对象的状态。所以我试着:
String update = "UPDATE Foo as foo SET foo.status = :status WHERE foo.id in (:idList)"这导致了一个例外:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;我也试过:
String update = "UPDATE Foo as foo SET foo.status = :status WHERE foo.id in (SELECT id FROM Foo WHERE id in (:idList))"导致了同样的例外。
我插入的参数如下:
StatelessSession ss = sessionFactory.openStatelessSession();
Query query = ss.createQuery(update);
query.setParameter("status", status);
query.setParameterList("idList", ids);
query.executeUpdate();有什么办法让这件事成功吗?提前感谢
发布于 2016-12-07 18:10:57
Status是一个MySQL保留字。将列重命名为其他内容
https://stackoverflow.com/questions/41024401
复制相似问题