Why does Hibernate try to delete when I try to update/insert?

后端 未结 4 599
独厮守ぢ
独厮守ぢ 2020-12-08 01:44

In my app I have these Hibernate-mapped types (general case):

class RoleRule {
  private Role role;
  private PermissionAwareEntity entity; // hibernate-mapp         


        
4条回答
  •  抹茶落季
    2020-12-08 01:59

    See the answer of the question 'Overriding equals and hashCode in Java'.

    It explains how to override the equals and hashCode methods, which seemed to be your problem as it worked after having them rewritten.

    Wrongly overriding them can lead hibernate to delete your collections and reinsert them. (as the hash key is used as keys in maps)

提交回复
热议问题