如题,我现在报这个错误:org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.bysj.songxy.domain.Teachers#2]
我用的是springmvc架构
DAO层:
public void update(T o){
getSession().update(o);
}
service层:
public ResultBase update(Long id,String password) {
ResultBase ret = new ResultBase();
Teachers teachers = new Teachers();
teachers.setId(id);
teachers.setPassword(Md5Util.md5Others(password));
teachersDAO.update(teachers);
ret.setResult(ResultBase.RESULT_SUCC);
return ret;
}
controller层:
public String goTpasswordchange(Long id,String oldpassword,String password, ModelMap map){
Teachers teachers = teachersService.findById(id);
map.addAttribute("id", id);
String Mpasseord=Md5Util.md5Others(oldpassword);
System.out.println(Mpasseord);
System.out.println(teachers.getPassword());
if(teachers.getPassword().equals(Mpasseord)){
teachersService.update(id,password);
System.out.println("修改成功");
return "main/Tindex";
}
else{
System.out.println("修改失败");
return "main/Tpasswordchange";
}
}
有木有大神知道怎么修改?很急,在线等