Hibernate级联删除报Cannot delete or update a parent row: a foreign key constraint fa

原文地址:http://michaeljscofield.iteye.com/blog/1871081

 在删除主表数据时,报了一个异常

Cannot delete or update a parent row: a foreign key constraint fails

 

原因是主表中还包含字表的数据,不能删除与这张表或数据有关联的字段,所以无法删除

 

解决办法:在创建数据库的外键时,将删除的动作配置由RESTRICT改成cascade,就可以解决



猜你喜欢

转载自blog.csdn.net/tanga842428/article/details/80280262