Hibernate的many-to-one 关联。
具体看配置文件:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.java1234.model"> <class name="Student" table="t_student">
<id name="id" column="stuId">
<generator class="native"></generator>
</id> <property name="name" column="stuName"></property>
<!-- 这里的many就是指的改xml对应的类Student,而one就指的班级Class -->
<many-to-one name="c" column="classId" class="com.java1234.model.Class" cascade="save-update"></many-to-one>
</class> </hibernate-mapping>