DocumentCatalog自身1对多,在hbm.xml文件中的写法
<set name="children" table="documentcatalog" cascade="all-delete-orphan" inverse="true" lazy="true"
order-by="order_">
<key column="parentId_"></key>
<one-to-many class="com.langsin.bean.DocumentCatalog" />
</set>
ont-to-many 有一个重要的属性设置lazy,设为true 时表示将1的这端加载到内存中,对于多这端不一定立即加载到内存中,也就是说只有
使用到多的这端,才从数据库中取出来并加载到内存中
DocumentCatalog 同时也是自身多对1,自己是多(省略不写),parent是1,写法如下:
<many-to-one name="parent" column="parentId_"
class="com.langsin.bean.DocumentCatalog"></many-to-one>