今天增加了2个小模块

今天增加了2个小模块
一个是维护栏目表的,目前只实现了简单的增加功能,栏目表最难搞的是实现一对多的自身关联(为了实现不受层次限制)。
另外一个是初步研究了如何实现Html编辑器,能将编辑完的内容存到表的字段中,就像在这里发表随笔的功能;
等这两个功能进一步完善后,就可以维护栏目和每个栏目下的内容,实现栏目内容的分类和在线维护

<hibernate-mapping package=".........................">
  <class name="Category" table="cms_categories" lazy="false">
    <id name="id" type="long" column="CATE_ID">
      <generator class="identity"/>
    </id>
    <property name="name" type="string" column="CATE_NAME" length="60" not-null="true"/>
    <set
       name="childCategories"
       cascade="save-update"
       inverse="true"
    >
       <key column="CATE_CATEGORY_ID" />
       <one-to-many class="Category" />
    </set>
    <many-to-one name="parentCategory" column="CATE_CATEGORY_ID" class="Category" cascade="none" />
  </class>
</hibernate-mapping>
另外哪位熟悉hibernate的朋友,帮我看看,上面是Category类的映射方法,不过当我写:
   Category category = new Category(categoryName);

   // find the new category's parent category object by the param parentCategoryId
   Category parentCategory = categoryDao.getCategory(parentCategoryId);

   if (parentCategory != null) {    
      category.setParentCategory(parentCategory);
      // parentCategory.getChildCategories().add(category);    ************
      categoryDao.save(category);
     ...............................


*******行如果不注释掉就会出Exception,哪位熟悉hibernate的朋友给指点一下

你可能感兴趣的:(今天增加了2个小模块)