Hibernate Delete Error: Batch Update Returned Unexpected Row Count

前端 未结 8 1768
余生分开走
余生分开走 2020-12-04 16:44

I wrote this method below that is suppose to delete a member record from the database. But when I use it in my servlet it returns an error.

MemberDao Class

8条回答
  •  孤城傲影
    2020-12-04 17:41

    In my case this exception was caused by wrong entity mapping. There were no cascade for relation, and referenced child entity wasn't saved before trying to reference it from parent. Changing it to

        @OneToMany(cascade = CascadeType.ALL)
    

    fixed the issue.

    Surely best way to find cause of this exception is setting show_sql and DEBUG level for logs - it will stop just at the sql that caused the problem.

提交回复
热议问题