Student实体 package com.yxfei.dojo; import java.io.Serializable; import java.util.List; public class Student implements Serializable { /** * */ private static final long serialVersionUID = 5948895832050257601L; private Integer id; private String stuName; private String sex; private Integer age; private List<Grade> grade; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getStuName() { return stuName; } public void setStuName(String stuName) { this.stuName = stuName; } public String getSex() { return sex; } public void setSex(String sex) { this.sex = sex; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public List<Grade> getGrade() { return grade; } public void setGrade(List<Grade> grade) { this.grade = grade; } } Student.hbm.xml文件 <?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> <class name="com.yxfei.dojo.Student" table="student"> <id column