/**
* @hibernate.class
* table="tree"
*/
public class Component {
private long id;
private String name;
private Component parent;
private Set children=new HashSet();
private Component(){}
public Component(String name){
this.name=name;
}
/**
* @hibernate.id
* generator-class = "native"
*/
public getId(){
return Id;
}
private setId(long id){
this.id=id;
}
/**
* @hibernate.property
* length="64"
* not-null="true"
*/
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
/**
* 獲得父節(jié)點(diǎn)
* @hibernate.many-to-one
* column="parentId"
*/
public Component getParent(){
return parent;
}
public void setParent(Component parent){
this.parent=parent;
}
/**
* 獲得子節(jié)點(diǎn)
* @hibernate.set
* lazy = "true"
* table = "tree"
* @hibernate.collection-key
* column = "parentId"
* @hibernate.collection-one-to-many
* class = "Component"
*/
public Set getChildren(){
return children;
}
private void setChildren(Set children){
this.children=children;
}
public void addChild(Component child){
children.add(child);
}
public void removeChild(Component child){
childrent.remove(child);
}
public void clearChildren(){
children=new HashSet();
}
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。