异常处理:Hibernate:a different object with the same identifier value was already associated with the ses

异常处理:Hibernate:a different object with the same identifier value was already associated with the session

问题出现原因:个人理解是在一同个事务中,session中已经存在一个与当前对象不同但是标识符相同的对象,导致无法修改操作

解决办法:共同一个对象操作

之前的错误代码:
new 一个对象之后,就会报错
异常处理:Hibernate:a different object with the same identifier value was already associated with the ses

改正之后可以正常使用的代码:
异常处理:Hibernate:a different object with the same identifier value was already associated with the ses
我使它们公用了一个category对象,结果就是可以进行正常的删除操作了