1.数据表goodscate:
id int(4) <pk>
parent_id int(4)
cate_no varchar(20)
cate_name varchar(40)
2.pojo类:
public class Goodscate implements Serilizable{
private Integer id;
private String cate_no;
private String cate_name;
private Goodscate parent;
private Set childs=new HashSet();
public Goodscate(){
}
}
3.hbm.xml
<hibernate-mapping package="com.lhb.vo">
<class name="Goodscate" table="goodscate">
<id name="id" column="id" type="integer">
<generator class="native"/>
</id>
<property name="cate_no" column="cate_no" type="string"/>
<property name="cate_name" column="cate_name" type="string"/>
<many-to-one name="parent" column="parent_id" class="com.lhb.vo.Goodscate" lazy="false"/>
<set name="childs" cascade="all" lazy="false" inverse="true">
<key column="parent_id"/>
<one-to-many class="com.lhb.vo.Goodscate"/>
</set>
posted on 2008-05-25 17:21
长春语林科技 阅读(1046)
评论(0) 编辑 收藏 所属分类:
hibernate