package com.xuguang.ext.xgerp.comm.workshop.bean;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.FetchType;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
/**
* 工作点
* @author ztw
*
*/
@Entity
@Table(name="comm_workshop")
public class WorkShop implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7502127838260795796L;
/**
* 关键字
*/
private String workshopPK;
/**
* 编号
*/
private String workshopNo;
/**
* 名称
*/
private String workshopName;
/**
* 类型
*/
private String workshopType;
/**
* 父
*/
private WorkShop father;
/**
* 子
*/
private List<WorkShop> sons;
@Id
public String getWorkshopPK() {
return workshopPK;
}
public void setWorkshopPK(String workshopPK) {
this.workshopPK = workshopPK;
}
public String getWorkshopNo() {
return workshopNo;
}
public void setWorkshopNo(String workshopNo) {
this.workshopNo = workshopNo;
}
public String getWorkshopName() {
return workshopName;
}
public void setWorkshopName(String workshopName) {
this.workshopName = workshopName;
}
public String getWorkshopType() {
return workshopType;
}
public void setWorkshopType(String workshopType) {
this.workshopType = workshopType;
}
@ManyToOne(targetEntity=WorkShop.class)
@JoinColumn(name="fatherPK")
@NotFound(action=NotFoundAction.IGNORE)
public WorkShop getFather() {
return father;
}
public void setFather(WorkShop father) {
this.father = father;
}
@OneToMany(mappedBy="father",fetch=FetchType.EAGER)
@OrderBy("workshopName")
public List<WorkShop> getSons() {
return sons;
}
public void setSons(List<WorkShop> sons) {
this.sons = sons;
}
}
oneToMany,ManyToOne双向关联
最新推荐文章于 2024-02-26 22:18:48 发布