Hibernate - clearing a collection with all-delete-orphan and then adding to it causes ConstraintViolationException

后端 未结 4 2035
独厮守ぢ
独厮守ぢ 2021-02-19 14:19

I have these entities

class Foo{
    Set bars;
}

class Bar{
    Foo parent;
    String localIdentifier;
}

With this mapping (sorry,

4条回答
  •  旧巷少年郎
    2021-02-19 14:49

    If you want to avoid flushing the session here, try to replace the whole list (new List() instead of Clear()). Hibernate should actually remove all the items in one shot before adding new. Just a try, not sure if it works.

提交回复
热议问题