A collection with cascade=“all-delete-orphan” was no longer referenced by the owning entity instance

后端 未结 5 1220
终归单人心
终归单人心 2021-02-01 07:26

In my application, a hibernate operation goes like this. The application updates a parent entity with new values from the request and deletes all the existing (previously insert

5条回答
  •  有刺的猬
    2021-02-01 08:08

    instead of setChilds use addAll ,

    from this,

        parent.getChilds().clear();
        parent.setChilds(newChilds);
    

    to

        parent.getChilds().clear();
        parent.getChilds().addAll(newChilds);
    

提交回复
热议问题