这是一个自关联的实体:
package com.mxlvniao.entity.dao;
import java.io.Serializable;
import java.util.List;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Many;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.Table;
@Table("tb_destination")
public class Destination implements Serializable {
private static final long serialVersionUID = -329026169568853770L;
@Name
private String id;
@Column
private String name;
@Column
private String pid;
@Column
private Integer qizhouId;
@Column
private Integer layer;
@Many(target = Destination.class, field = "pid")
private List<Destination> children;
// 怎么关联父类实体,我不知我这么写对不对?
@ManyMany(target = Destination.class, relation = "t_destination", from = "pid", to = "id")
private Destination parentDest;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Integer getQizhouId() {
return qizhouId;
}
public void setQizhouId(Integer qizhouId) {
this.qizhouId = qizhouId;
}
public Integer getLayer() {
return layer;
}
public void setLayer(Integer layer) {
this.layer = layer;
}
public List<Destination> getChildren() {
return children;
}
public void setChildren(List<Destination> children) {
this.children = children;
}
public Destination getParentDest() {
return parentDest;
}
public void setParentDest(Destination parentDest) {
this.parentDest = parentDest;
}
}