org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1


 

在使用hibernate更新數據庫記錄的信息時,出現org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 錯誤。

原因分析: 
我在更新數據時,顯式地使用了id的setId()方法為其指定值。但是我的實體類的id指定了主鍵生成策略(@GeneratedValue(strategy = GenerationType.AUTO)),此時不能顯式使用setId()方法設置id的值。

解決方法: 
不要顯式地使用setId方法設置主鍵值。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM