【发布时间】:2010-08-27 02:58:39
【问题描述】:
在hibernate中有很多关于set cascade to "all, delete"等的信息, 但我想知道将级联设置为“无”的效果
现在我有一个类 Parent,它是子类 Child,
class Parent{
List<Child> childs;
....}
在文件parent.hbm.xml中(其他内容我省略了)
<class name="Parent" table="parent" >
<bag name="childs" lazy="false" table="parenthaschildsTable" cascade="none">
<key>
<column name="parentId" not-null="true"/>
</key>
<one-to-many class="Child">
<column name="childId" not-null="true"/>
</one-to-many>
</bag>
当保存父级时,我不想级联更新他的子级,所以我设置了cascade="none"。
我的问题是:
我将级联设置为“无”,如果我将一个child#1添加到父级,然后我保存父级,可以休眠向表parenthaschildsTable插入一条新记录,但不能级联Child?
【问题讨论】:
标签: java hibernate cascade nhibernate-cascade