deleted object would be re-saved by cascade (remove deleted object from associations)

后端 未结 18 1151
轮回少年
轮回少年 2020-11-30 00:19

i have the following two entities:

1- PlayList:

@OneToMany(fetch = FetchType.EAGER, mappedBy = \"playlist\", orphanRemoval = true, c         


        
18条回答
  •  温柔的废话
    2020-11-30 01:10

    The solution is to do exactly what the exception message tells you:

    Caused by: org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)

    Remove the deleted object from an associations (sets, lists, or maps) that it is in. In particular, i suspect, from PlayList.PlaylistadMaps. It's not enough to just delete the object, you have to remove it from any cascading collections which refer to it.

    In fact, since your collection has orphanRemoval = true, you don't need to delete it explicitly. You just need to remove it from the set.

提交回复
热议问题