听说这里高手多,请教来了。
JAVA.......hibernate修改数据, 更新不了。(SSH.使用的spring整合里面的.hibernateTemplate)
映射文件:
<property name="connection.autocommit">true</property>设置了自动提交事务
Dao层:
public boolean updatePassword(String username,String password, String repassword) {
// TODO Auto-generated method stub
String hql="from Usersinfo where username =?";
boolean validate= this.findPassword(username, password);
System.out.println(validate);
if(validate)
{
List<Usersinfo> list=this.hibernateTemplate.find(hql,username);
Usersinfo usersinfo=list.get(0);
System.out.println(usersinfo.getPassword());
usersinfo.setPassword(repassword);
System.out.println(usersinfo.getPassword());
this.hibernateTemplate.saveOrUpdate(usersinfo);
return true;
}
else{
return false;
}
}
Struts..action
:
public ActionForward updatePassword(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
DynaActionForm userForm = (DynaActionForm) form;
String username = userForm.getString("username");
String password = userForm.getString("password");
String repassword = userForm.getString("repassword");
boolean flag=userService.updatePassword(username, password, repassword);
if(flag)
{
request.setAttribute("res", "success");
return mapping.findForward("updateSuc");
}
else{
request.setAttribute("res", "error");
return mapping.findForward("updateSuc");
}
}
为什么更新不了数据呢???