NonUniqueObjectException: A different object with the same identifier value was already associated

org.springframework.dao.DuplicateKeyException: A different object with the same identifier value was already associated with the session : [com.chuai.pojo.Department#14]; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session : [com.chuai.pojo.Department#14]
在这里插入图片描述
解决:
在这里插入图片描述
使用ssh框架进行update()操作的时候,出现id被占用的情况,查询资料得知是hibernate一级缓存的缘故,可在update之前,去dao层调用clera()方法清除session

猜你喜欢

转载自blog.csdn.net/weixin_44142296/article/details/85055251
今日推荐