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

 

在使用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的值。hibernate

解决方法: 
不要显式地使用setId方法设置主键值。code

相关文章
相关标签/搜索