如何使用bulkUpdate执行hibernateTemplate操作。下面的代码抛出
由:org.hibernate.QueryParameterException引起:超过声明序数参数数的位置。记住序数参数是基于1的!职位:2
HibernateTemplate.bulkUpdate("update Address address set address.city = 'Oakland' where address.user in (:users)", users);如何通过传递用户列表作为参数来实现此批更新操作?
发布于 2015-09-11 07:19:35
这个问题可能与why-this-hibernate-template-bulkupdate-doesnt-work重复。
以上问题的回答可以解决这个问题。希望能帮上忙。快乐学习:)
发布于 2017-03-14 12:08:09
它很奇怪,我搜索了很多,也找不到解决方案,医生说它是绑定数的值“?查询字符串中的参数,但当我将list作为参数提供时,它并不是将in子句绑定为string。因此,我以字符串的形式提供了一个变通的参数:
StringBuilder inClauseparams = new StringBuilder("(");
for (int i = 0; i < notificationIDs.size(); i++) {
inClauseparams.append(""+notificationIDs.get(i));
if( i != notificationIDs.size()-1 )
inClauseparams.append(",");
else
inClauseparams.append(")");
}
hibernateTemplate.bulkUpdate("update Notification set isSeen = true where id in "+inClauseparams.toString());https://stackoverflow.com/questions/25849605
复制相似问题