TA的每日心情  | 开心 2021-3-12 23:18 | 
|---|
 
  签到天数: 2 天 [LV.1]初来乍到  
 | 
 
| 
 
  
结果: 
一方的数据会删除,但是多方的数据不会删除,而多方的外键会被置为空(如果外键为null情况,否则报错无法删除,事物回滚)。 
执行过程: 
Hibernate: select qx0_.qxid as qxid1_0_, qx0_.qx as qx1_0_ from zf.dbo.TBL_QX qx0_ where qx0_.qxid=? 
Hibernate: update zf.dbo.TBL_JD set qxid=null where qxid=? 
Hibernate: delete from zf.dbo.TBL_QX where qxid=? 
解决方法: 
在manytoone.hib.xml中的配置中添加inverse=true 
执行过程:(先删除多的一方的数据,再删除一方的数据) 
Hibernate: select qx0_.qxid as qxid1_0_, qx0_.qx as qx1_0_ from zf.dbo.TBL_QX qx0_ where qx0_.qxid=? 
Hibernate: select jds0_.qxid as qxid1_, jds0_.jdid as jdid1_, jds0_.jdid as jdid0_0_, jds0_.jd as jd0_0_, jds0_.qxid as qxid0_0_ from zf.dbo.TBL_JD jds0_ where jds0_.qxid=? 
Hibernate: delete from zf.dbo.TBL_JD where jdid=? 
Hibernate: delete from zf.dbo.TBL_JD where jdid=? 
Hibernate: delete from zf.dbo.TBL_JD where jdid=? 
Hibernate: delete from zf.dbo.TBL_JD where jdid=? 
Hibernate: delete from zf.dbo.TBL_QX where qxid=? 
 
 |   
 
 
 
 |