ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)解决方法
org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)解决方法:
1. To delete a Parent:
a. Make sure your Parent is not associated to any parent.
b. Delete the Parent and all connected Child will be too.
2. To delete a Child:
a. Remove the Child from the Sets from all Parentes asigned to.
b. Save the Parent which had the Child and the Child will be vanished too. (There is no need to delete it explicit.)
3. 删除Set方的cascade
4. 解决关联关系后,再删除 :
parent.getChildrens().remove(child);
child.setParent(null);
dao.removeChild(child);
5. 在many-to-one方增加cascade 但值不能是nonechild.setParent(null);
dao.removeChild(child);