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都不行,请各位大神求教?

  • 相关阅读:
    Domino
    tomcat 部署 外网访问
    市场4
    android 源码下载编译
    SSIS
    代码审查工具
    mfc 常用控件
    屏蔽home
    MFC BEGIN_MESSAGE_MAP()
    社交产品
  • 原文地址:https://www.cnblogs.com/yhiloon/p/3656458.html
Copyright © 2011-2022 走看看