Deleted entity passed to persist exception

前端 未结 4 1024
情歌与酒
情歌与酒 2021-02-08 13:57

I have this kind of entities:

Document | n .. to ..1 | DocumentType | 1 .. to .. n | PropertyType | 1 .. to

4条回答
  •  礼貌的吻别
    2021-02-08 14:42

    I assume you have called remove() on an of type PropertyType before. Call remove() only for the "root" entity, and remove the others with something like:

    document.getDocumentType().getPropertyTypes().remove(propertyType);
    

    And retain the DELETE_ORPHAN

    You can then, after verifying you haven't manually called remove() on other entities, try calling:

    document = entityManager.merge(document);
    entityManager.remove(document);
    

    so that the EntityManager reassociates the object with the session first.

提交回复
热议问题