@Entity
@Table(name="Organazition")
public class Organazition {
private int id;
private String name;
private String sn;
private Organazition parent;
private Set<Organazition> children=new HashSet();
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
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 String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
@ManyToOne
@JoinColumn(name="parentId")
public Organazition getParent() {
return parent;
}
public void setParent(Organazition parent) {
this.parent = parent;
}
@OneToMany(mappedBy="parent",fetch=FetchType.LAZY,cascade=CascadeType.ALL)
public Set<Organazition> getChildren() {
return children;
}
public void setChildren(Set<Organazition> hchildrenildren) {
this.children = hchildrenildren;
}
}