a different object with the same identifier value was already associated with the session:

来源:互联网 发布:封锁 张爱玲 知乎 编辑:程序博客网 时间:2024/05/29 07:28

编程时遇到的一个经典错误。

a different object with the same identifier value was already associated with the session: [com.tarena.oa.pojo.Department#15]

经过排查,原来是代码保存时的错误。

public String edit() throws Exception{Department department=departmentService.getById(model.getId());department.setDescription(model.getDescription());department.setName(model.getName());department.setParent(departmentService.getById(parentId)); // 上级部门departmentService.update(model);return "toList";}

departmentService.update(model)时错误

应该是

departmentService.update(department);

原创粉丝点击