其實單一實體的一對多和多對一和2個實體的用法是一樣的,現在以user為例:
java程式碼:
package com.test.bean;
package com.test.bean; .util.Set;
public class User
{
private Integer id;
private String firstname;
private String lastname;private private User user;
public Set getChildrens() {
return childrens; }
public void setChildrens(Set childrens) {
this.childrens = user;
}
this.user = user;
}
{
return id;
}
public String getFirstname()
{
return firstname;
}
public void setFirstname(String firstname)
public void setFirstname(String firstname)
{
return lastname;
}
{
this.lastname = lastname;
}
}
public int getAge()
{
{
this.age = age;
}
return parentID;
}
public void setParentID(Integer parentID) {
對應的hbm檔:
"java.lang.Integer" column="age"> lazy="false" where=" age=4">