private long zoneId;
private String zoneName;
private String zoneDis;
private Date createTime;
private long topicNum;
private Set<Topic> topic = new HashSet<Topic>(); //主题
......
}
private long topicId;
private String topicTitle;
private String topicContent;
private Date sendTime;
private User user;
private long FeedNum;
private Zone zone;//板块
......
/get set 方法省去
}
<class name="Zone" table="zone">
<id name="zoneId" column="zoneid" type="long">
<generator class="native"/>
</id>
<property name="zoneName" column="zonename" type="string"/>
<property name="zoneDis" column="zoneDis" type="string"/>
<property name="createTime" column="createTime" type="timestamp"/>
<property name="topicNum" column="topicNum" type="long"/>
<!-- inverse=true 说明不是主控方。一般多的一方为主控方。-->
<set name="topic" table="topic" cascade="all" inverse="true">
<key column="zoneId" not-null="true"/>
<one-to-many class="Topic"/>
</set>
</class>
</hibernate-mapping>
<class name="Topic" table="topic">
<id name="topicId" column="topicId" type="long">
<generator class="native"/>
</id>
<property name="topicTitle" column="topicTitle" type="string"/>
<property name="topicContent" column="topicContent" type="string"/>
<property name="sendTime" column="sendTime" type="timestamp"/>
<property name="FeedNum" column="FeedNum" type="long"/>
<many-to-one name="zone" class="Zone" fetch="select" >
<column name="zoneId" />
</many-to-one>
</class>
</hibernate-mapping>