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