这是我的更新查询
StringBuilder queryString = new StringBuilder("update CloudSvrUsersSecQuestion c set c.secQuesAnswer=");
// it will call five times for 5 db recod the below query
for(CloudSvrUsersSecQuestion lisq:user.getListSecQuestion()) {
queryString.append("' ").append(lisq.getSecQuesAnswer()).append("' ").append("where c.secQuesId=").append(lisq.getSecQuesId());
}
// how to execute this query for updating in db below is my approach but its not correct
CloudSvrUsersSecQuestion my pojo class mapped with db
secQuesList = (List<CloudSvrUsersSecQuestion>)super.getHibernateTemplate().update(queryString.toString());
请帮我解释如何编写执行此查询
答案 0 :(得分:0)
您必须使用Hibernate Template的bulkUpdate方法。
另请参阅此链接以了解类似问题 - 如何使用HibernateTemplate和HQL更新查询?enter link description here