日期:2014-05-19 浏览次数:20816 次
public class TA extends TObject{
private Set tbs=new HashSet(0);
public Set getTbs() {
return tbs;
}
public void setTbs(Set tbs) {
this.tbs = tbs;
}
}
public class TB extends TObject {
private TA ta;
public TA getTa() {
return ta;
}
public void setTa(TA ta) {
this.ta = ta;
}
}
<?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">
<hibernate-mapping package="test">
<class name="TA" table="TA">
<id name="id" type="long" column="ta_id">
<generator class="native" />
</id>
<property name="name" column="name" type="string" />
<set name="tbs">
<key column="ta_id"></key>
<one-to-many class="TB" />
</set>
</class>
</hibernate-mapping>
<?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">
<hibernate-mapping package="test">
<class name="TB" table="TB" polymorphism="explicit">
<id name="id" type="long" column="tb_id">
<generator class="native" />
</id>
<property name="name" column="name" type="string" />
<many-to-one name="ta" column="ta_id" class="TA" />
</class>
</hibernate-mapping>