日期:2014-05-17 浏览次数:20623 次
package com.lh.entity;
public class Address {
private int id;
private String address_detil;
private Student student;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAddress_detil() {
return address_detil;
}
public void setAddress_detil(String addressDetil) {
address_detil = addressDetil;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
}
package com.lh.entity;
public class Student {
private int id;
private String name;
private Address address;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.lh.entity">
<class name="Address">
<id name="id" column="address_id">
<generator class="native" />
</id>
<property name="address_detil"/>
<one-to-one name="student" property-ref="address" cascade="delete" />
</class>
</hibernate-mapping>
<?xml version="1.0"?>