Hibernate之deleted object would be re-saved by cascade异常

在Hibernate中,删除存在关联关系的一个对象时,会出现 org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)这个异常

解决方案如下:
方法1 删除Set方的cascade
方法2 解决关联关系后,再删除 :
//移除关联关系
webSite.getTemplates().remove(template);
//删除
templateService.delete(template);
方法3 在many-to-one方增加cascade 但值不能是none

参考,http://www.blogjava.net/crazycy/archive/2006/06/24/54939.html

你可能感兴趣的:(html,.net,Hibernate)