In hibernate, there are many information about set cascade to "all, delete" and so on, but I want to know the effect of set cascade to "none"
now I have a class Parent, and it's child-class Child,
class Parent{
List<Child> childs;
....}
and in the file parent.hbm.xml(I omitted other content)
<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>
when save the parent, I don't want to cascade update his childs, so I set cascade="none"
.
my question is :
I set the cascade is "none", if I add a child#1 to parent, then I save the parent, can hibernate insert a new record to the table parenthaschildsTable, but not cascade the Child?
I set the cascade is "none", if I add a child#1 to parent, then I save the parent, can hibernate insert a new record to the table parenthaschildsTable, but not cascade the Child?
You changed the parent (by modifying a collection) so Hibernate will insert a record in the join table to reflect that on save (when should it happen else?). And of course this will only succeed if the child has already an identifier value assigned. But why don't you try it actually?