<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.pojo.T" table="t">
<id name="tid" type="java.lang.Integer">
<column name="tid" />
<generator class="native" />
</id>
<property name="tname" type="java.lang.String">
<column name="tname" length="10" not-null="true" />
</property>
<set name="s"[关联字段名] table="st" [关联表]cascade="save-update" inverse="false"[老师选学生,主动权]>
<key column="tid"[对应关联表字段]></key>
<many-to-many class="com.pojo.S"[关联类] column="sid"[关联类字段]>
</many-to-many>
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.pojo.S"[学生pojo类] table="s"[学生表]>
<id name="sid"[学生表主键字段名] type="java.lang.Integer"[主键类型]>
<column name="sid" />
<generator class="native"[主键生成方式] />
</id>
<property name="sname" type="java.lang.String">
<column name="sname" length="10" not-null="true" />
</property>
<set name="t"[学生pojo类的老师属性字段] table="st"[老师学生关联表] cascade="save-update" inverse="true"[主动控制权]>
<key column="sid"[对应老师关联表属性]></key>
<many-to-many class="com.pojo.T"[老师表] column="tid"[老师表ID]>
</many-to-many>
</set>
</class>
</hibernate-mapping>
create table s(
sid number primary key,
sname varchar2(20)
)
create table t(
tid number primary key,
tname varchar2(20)
)
create table st(
sid number,
tid number
)