我有一个单向关系映射如下:
@OneToMany(orphanRemoval=true)
@JoinColumn(name="parent_id", referencedColumnName="id", nullable=false, insertable=true)
private List<Child> children= new ArrayList<Child>();
正在内联没有存储库的Child,我发布application/merge-patch+json
填充如下:
{
"children": [
{
"key": "value"
}
]
}
没有orphanRemoval
,这可以正常工作,但如果我覆盖关联,我有孤立的记录,其中空FK指向父母。如果我添加orphanRemoval属性,请求500s说明:
A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance
非常感谢任何帮助,谢谢!
编辑:我将nullable更新为false,并解决了级联问题,但现在我不确定如何从列表中删除元素。