Hibernate不会使用orphanRemoval

时间:2018-12-07 07:35:33

标签: java hibernate jpa spring-data-jpa

代码在github中共享。情况看起来像这样,我已经打开交易。我创建了ExampleEntity和ExampleChildEntity。它们通过双向参考连接。我要采取的步骤:

ExampleEntity.setChild(child);
saveAndFlush() // insert goes to db
ExampleEntity.setChild(null)
saveAndFlush() // delete goes to db
ExampleEntity.setChild(child)
saveAndFlush() // insert goes to db
ExampleEntity.setChild(null)
saveAndFlush() // no delete here

我标记了hibernate,因为我认为这是Hibernate问题(我正在使用spring数据jpa),因为当我将JPA提供程序切换到EclipseLink时,一切都进行得很好。我是在做错什么还是错误?我尝试将对父级的子级引用设置为null,但这也不起作用。示例项目: https://github.com/pustypawel/delete-twice-bug

0 个答案:

没有答案
相关问题