Hibernate cascade问题
<class name="Category" table="CATEGORY">
...
<property name="name" column="CATEGORY_NAME"/>
<many-to-one
name="parentCategory"
class="Category"
column="PARENT_CATEGORY_ID"
cascade="none"/>
<set
name="childCategories"
table="CATEGORY"
cascade="save-update"
inverse="true">
<key column="PARENT_CATEGORY_ID"/>
<one-to-many class="Category"/>
</set>
...
</class>
Session session = sessions.openSession();
Transaction tx = session.beginTransaction();
Category computer = (Category) session.get(Category.class, computerId);
Category laptops = new Category("Laptops");
computer.getChildCategories().add(laptops); (1)
laptops.setParentCategory(computer); (2)
tx.commit();
session.close();
执行(1)的时候,PARENT_CATEGORY_ID字段 是不是没有被设置?
设置这个字段是执行(2)的时候,执行了一个update sql语句?