日期:2014-05-18 浏览次数:20756 次
public class User implements Serializable {
private int id;
private String name;
private int age;
private Set<Book> book;
public Set<Book> getBook() {
return book;
}
public void setBook(Set<Book> book) {
this.book = book;
}
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 int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
<?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>
<class name="com.example.pojo.User" table="user">
<id name="id">
<column name="id" />
<generator class="identity"/>
</id>
<property name="name"/>
<property name="age"/>
<set name="book" table="userbook" lazy="false">
<key column="userid"/>
<many-to-many class="com.example.pojo.Book" column="bookid" />
</set>
</class>
</hibernate-mapping>