标签:
<?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.sn.domain.Classes"> <id name="cid" type="java.lang.Long" length="5"> <generator class="increment"></generator> </id> <property name="name" length="20"></property> <property name="description" length="50"></property> <set name="students" cascade="all" inverse="false"> <key> <column name="cid"></column> </key> <one-to-many class="com.sn.domain.Student"/> </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> <class name="com.sn.domain.Student"> <id name="sid" type="java.lang.Long" length="5"> <generator class="increment"></generator> </id> <property name="name" length="20"></property> <property name="description" length="50"></property> </class> </hibernate-mapping>
public class Classes implements Serializable { private Long cid; private String name; private String description; private Set<Student> students; public Long getCid() { return cid; } public void setCid(Long cid) { this.cid = cid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Set<Student> getStudents() { return students; } public void setStudents(Set<Student> students) { this.students = students; } }
public class Student implements Serializable{ private Long sid; private String name; private String description; public Long getSid() { return sid; } public void setSid(Long sid) { this.sid = sid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } }
标签:
原文地址:http://www.cnblogs.com/jsnan/p/4525646.html