1. 程式人生 > >NonUniqueObjectException: A different object with the same identifier value was already associated

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