本文主要是介绍解决hibernate 删除异常: deleted object would be re-saved by cascade (remove deleted object from associatio,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在hibernate 删除关联时会出现eleted object would be re-saved by cascade (remove deleted object from associations)的异常,结合别人的和自己的经验通常有三种解决的方案:
方法1 删除Set方的cascade:
方法2 解决关联关系后,再删除
thisMany.setOne( null ); // 设置所对应的一方为空,解除它们之间的关系
manyDao.delete(thisMany);
方法3 在many-to-one方增加cascade 但值不能是none
这篇关于解决hibernate 删除异常: deleted object would be re-saved by cascade (remove deleted object from associatio的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!