JPA 2.0 / Hibernate and “orphanRemoval”: Just replacing an entity does not remove the old one

前端 未结 2 1201
故里飘歌
故里飘歌 2020-12-31 05:41

I have question regarding JPA 2.0, Hibernate and \"orphanRemoval\".

First my setup:

  • Spring 3.0.5.RELEASE
  • SprnigData JPA 1.0.1.RELEASE
相关标签:
2条回答
  • This is related to Hibernate JIRA tickets HHH-5559 and HHH-6484. By and large, Hibernate, as of today, requires you to set the reference to null and flush the persistence context, before providing a new value to the relationship (see the test case in HHH-6484); it is only in such a case that Hibernate issues a SQL DELETE statement, providing a broken implementation (IMHO) for orphanRemoval.

    In short, you'll need to wait for the bugs to be fixed, or write code to nullify references and flush the persistence context, or use a JPA provider that supports orphanRemoval in this manner (EclipseLink 2.3.0 does).

    0 讨论(0)
  • 2020-12-31 06:01

    As of @OneToMany relationship, this is related to Hibernate JIRA ticket HHH-6709. Please vote for these so it get some attention.

    0 讨论(0)
提交回复
热议问题