zoukankan      html  css  js  c++  java
  • hibernate4的级联删除为什么不行啊?

    我刚刚在做部门模块,结果在部门树形结构下想删除某个节点,一带把他的子节点也删除了,但如何设置都发现删除不了,会报出错误:

    1. Cannot delete or update a parent row: a foreign key constraint fails (`oa`.`department`, CONSTRAINT `FK_rll3cq4b2ghx2lmgj6c31o70m` FOREIGN KEY (`parentDept_id`) REFERENCES `department` (`id`))
    2. could not execute statement
    3. could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

    我在实体上设置了级联操作了:

    @OneToMany(mappedBy="parentDept",cascade=CascadeType.REMOVE,fetch=FetchType.EAGER)
    public Set<Department> getChildDepts() {
    return childDepts;
    }

    不管我设置的是ALL还是REMOVE都不行,请各位大神求教?

  • 相关阅读:
    知识点
    Python基础 (下)
    Python基础 (上)
    RESTful和SOAP的区别
    Maven
    centos7下配置的php命令
    centos7下的nginx命令配置
    CentOS 7.4下使用yum安装MySQL5.7.20 最简单的
    word下载
    phpExcel导出表格
  • 原文地址:https://www.cnblogs.com/yhiloon/p/3656458.html
Copyright © 2011-2022 走看看