Hibernate在级联删除前要先把外键字段置为null,如果这个外键字段不允许为空,则会报错。
需要在many端设置参数:inverse=“true”,hibernate文档中有如下描述:
Very Important Note: If the <key> column of a <one-to-many> association is declared NOT NULL, Hibernate may cause constraint violations when it creates or updates the association. To prevent this problem, you must use a bidirectional association with the many valued end (the set or bag) marked as inverse="true".