遥想当时正在学hibernate的时候,刚好学到了一对多,多对多的关联操作。时间也正是刚好在那是有了一个项目,把各表的间的结构还理清,俗话说学到就要用到,就把这些表的结构都能配置级联关系的都把它配上。没想到就在这里给自己放了个小坑。前几天在一个帖子中看到别人说,尽量少配些ORM约束,数据库的外键约束什么的。当时还不以为然。没想到我就遇到了这个问题,或许对数据库操还是不是很熟悉的人约束真的不要配太多。不过有自然有其的好处就是。 今天在删除一张表的数据的时候报了如下错误: 1 2 3 4 5 6 7 8 9 10 11 12 13 09:55:49.144 [http-nio-8080-exec-6] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Cannot delete or update a parent row : a foreign key constraint fails ( `checkin` . `right_umenu` , CONSTRAINT `FKnmg8itd642tdyn6qh1q42h60r` FOREIGN KEY ( `menu_detailPid` ) REFERENCES `menu_detail` ( `id` )) 09 : 55 : 49.151 [ http -nio -8080 -exec -6 ] ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [could not execute statement ] org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java: 59 ) at org.hibernate.exception.internal...