Cannot delete or update a parent row: a foreign key constraint fails (hibernate xml mapping)

后端 未结 1 1953
栀梦
栀梦 2021-01-07 11:34

I would like to delete all the groups among which a user is an owner but it does not work at the moment. I think that there is something which is lacking at the level of the

1条回答
  •  孤城傲影
    2021-01-07 11:43

    Please try adding the inverse=true to User file set name proprietary also with cascade=all",delete-orphan

    which deletes the Groups when the User is deleted. Also please be extremely careful of how you delete User in Hibernate:

    Session must be flushed prior to deleting User.
    All Groups linked to your User must be evicted from all active sessions and 2nd level cache.

    0 讨论(0)
提交回复
热议问题