当前位置: 代码迷 >> Java Web开发 >> hibernate 级联更新的有关问题
  详细解决方案

hibernate 级联更新的有关问题

热度:11   发布时间:2016-04-16 22:06:15.0
hibernate 级联更新的问题
有一张Category表,一张Topic表,Topic表中有个外键cid对应Category表中的主键,我用update更新category中某条记录的其他数据时,Hibernate: update Category set name=?, description=? where cid=?
Hibernate: update Topic set cid=null where cid=?    后面这条使得Topic中的外键都断开了,求帮助,新手
------解决方案--------------------
更新category中某条记录的其他数据时,Hibernate: update Category set name=?, description=? where cid=?

下面这条Hibernate: update Topic set cid=null where cid=?  你是干嘛用的?
------解决方案--------------------
引用:
更新category中某条记录的其他数据时,Hibernate: update Category set name=?, description=? where cid=?

下面这条Hibernate: update Topic set cid=null where cid=?  你是干嘛用的?
楼主的意思是这条语句是hibernate自动帮你写的吗
------解决方案--------------------


引用:
Quote: 引用:

更新category中某条记录的其他数据时,Hibernate: update Category set name=?, description=? where cid=?

下面这条Hibernate: update Topic set cid=null where cid=?  你是干嘛用的?
下面这条也是hibernate自动生成的,就是不想要这句

把配置文件里面改成 cascade="none"
  相关解决方案