Java Jpa实体条件关系映射?
我有个人课和区域课 如果人员类型负责,则应采用一对一双向 如果人员类型为GARD,则应采用多对一 有没有办法做到这一点 对于初学者,我想提供以下内容,但@Where注释似乎无法识别:Java Jpa实体条件关系映射?,java,jpa,uml,entity-relationship,Java,Jpa,Uml,Entity Relationship,我有个人课和区域课 如果人员类型负责,则应采用一对一双向 如果人员类型为GARD,则应采用多对一 有没有办法做到这一点 对于初学者,我想提供以下内容,但@Where注释似乎无法识别: @Entity public class Personnel implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int Id; priva
@Entity
public class Personnel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int Id;
private String nom;
private String prenom;
private int Age;
private Date dateDeRecretement;
private String Login;
private String password;
@Enumerated(EnumType.STRING)
private TypePoste poste;
@Where(clause = "poste = 'GARDE_NUIT'")
@ManyToOne
private Zone zone;
@Where(clause = "poste = 'GARDE_JOUR'")
@ManyToOne
private Zone zone1;
@Where(clause = "poste = 'RESPONSABLE'")
@ManyToOne
private Zone zone2;
private static final long serialVersionUID = 1L;
public Personnel() {
super();
}
public int getId() {
return this.Id;
}
public void setId(int Id) {
this.Id = Id;
}
public String getNom() {
return this.nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return this.prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public int getAge() {
return this.Age;
}
public void setAge(int Age) {
this.Age = Age;
}
public Date getDateDeRecretement() {
return this.dateDeRecretement;
}
public void setDateDeRecretement(Date dateDeRecretement) {
this.dateDeRecretement = dateDeRecretement;
}
public String getLogin() {
return this.Login;
}
public void setLogin(String Login) {
this.Login = Login;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public TypePoste getPoste() {
return this.poste;
}
public void setPoste(TypePoste poste) {
this.poste = poste;
}
public Zone getZone() {
return zone;
}
public void setZone(Zone zone) {
this.zone = zone;
}
public Zone getZone1() {
return zone1;
}
public void setZone1(Zone zone1) {
this.zone1 = zone1;
}
public Zone getZone2() {
return zone2;
}
public void setZone2(Zone zone2) {
this.zone2 = zone2;
}
}
这是一个UML图,用来表示我试图实现的目标
您可以添加一个简单的约束,如
这个约束可以写成一个好的OCL。但是a)我对OCL没有那么坚定,b)编码人员应该能够以这种方式正确地实现它。您可以添加一个简单的约束,如 这个约束可以写成一个好的OCL。但是a)我对OCL没有那么坚定,b)编码人员应该能够以这种方式正确实现它