请问下各位,你们在用SSH批量删除数据是怎么样优化的?谢谢
[code="java"]
public String staffDel() throws IOException{
String pid = Param.get("pid");
pid = pid.replace(",", "','");
try {
String hql = "delete BsStaff where staffNo in ('"+pid+"')";
bsStaffService.hqlExecuteUpdate(hql, null);
log.warn("操作员:"+Param.getUserStaffName()+"\t删除了员工staffNo为:" + pid);
return staffList();
} catch (Exception e) {
PrintWriter out = ServletActionContext.getResponse().getWriter();
out.println("");<br> out.println("alert('删除失败,此记录已被其他信息引用!');location='"+Param.getAction("staff!staffList.action")+"'");<br> out.println("");
return null;
}
}
[/code]
删除信息,就不要使用hibernate对象去操作了,使用原始的sql语句操作就可以了,
还有不要使用循环,使用sql的in()的方法就可以了。其他就没有什么了