@Entity
@DiscriminatorValue("员工")
public class Employ extends Person4 {
private String title;
private double salary;
@ManyToOne(cascade=CascadeType.ALL,targetEntity=Manger.class)
@JoinColumn(name="manger_id",nullable=true)
private Manger manger;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public Manger getManger() {
return manger;
}
public void setManger(Manger manger) {
this.manger = manger;
}
}
@Entity
@DiscriminatorValue("经理")
public class Manger extends Employ {
private String department;
@OneToMany(cascade=CascadeType.ALL
, mappedBy="manger" , targetEntity=Employ.class)
private Set<Employ> employs=new HashSet<Employ>();
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public Set<Employ> getEmploys() {
return employs;
}
public void setEmploys(Set<Employ> employs) {
this.employs = employs;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。