0
enter image description here내가 이미 존재하는 프로젝트에 자바 퍼시스턴스 API를 사용하여 그림과 같이 내가 최대 절전 모드 사용 리버스 엔지니어링 한 각 그의 id.Before에 따라 보장하기 위해 상대 직원당이있어
지속성 엔티티를 configurate 엔티티를 생성하는 데는이 케이스를 다루는 방법을 모르겠다. "Adminisitrateur"엔티티를 다른 용어로 고용주와 연결하는 것을 돕는 것이 가능하다면 "administrateur"는 친척이 될 것임을 확신합니다. 가능하다면 거의 설명하지 않은 감사합니다. 여기
엔티티의 지속성 코드 : 사용자 개체 :package persistence;
import java.io.Serializable;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity(name = "User")
public class User implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
private String prenom;
@Column(unique = true)
private String matricule;
private String password;
@Column(unique = true)
private String email;
@OneToMany(mappedBy = "employer", fetch = FetchType.EAGER)
private Set<Demande> demandes;
private static final long serialVersionUID = 1L;
public User() {
}
public User(String name, String prenom, String matricule, String password, String email) {
super();
this.name = name;
this.prenom = prenom;
this.matricule = matricule;
this.password = password;
this.email = email;
}
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 getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Set<Demande> getDemandes() {
return demandes;
}
public void setDemandes(Set<Demande> demandes) {
this.demandes = demandes;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getMatricule() {
return matricule;
}
public void setMatricule(String matricule) {
this.matricule = matricule;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
고용주 단체 :
package persistence;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
/**
* Entity implementation class for Entity: Employer
*
*/
@Entity
public class Employer extends User implements Serializable {
@OneToMany(mappedBy = "employerRelative", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<Assure> assures;
private static final long serialVersionUID = 1L;
public Employer() {
}
public Employer(String name, String prenom, String matricule, String password, String email) {
super(name, prenom, matricule, password, email);
}
public List<Assure> getAssures() {
return assures;
}
public void setAssures(List<Assure> assures) {
this.assures = assures;
}
public void linkAssures(List<Assure> assures) {
this.assures = assures;
for (Assure a : assures) {
a.setEmployerRelative(this);
}
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
Administrateur 엔티티 :
package persistence;
import java.io.Serializable;
import javax.persistence.*;
import persistence.User;
/**
* Entity implementation class for Entity: Administrateur
*
*/
@Entity
public class Administrateur extends User implements Serializable {
private static final long serialVersionUID = 1L;
public Administrateur() {
super();
}
public Administrateur(String name, String prenom, String login, String password, String email) {
super(name, prenom, login, password, email);
// TODO Auto-generated constructor stub
}
}
실체를 확인한다 : 패키지 지속성을;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
/**
* Entity implementation class for Entity: Assure
*
*/
@Entity
public class Assure extends User implements Serializable {
@ManyToOne
private Employer employerRelative;
private String type;
private static final long serialVersionUID = 1L;
public Assure() {
super();
}
public Assure(String name, String prenom, String matricule, String password, String email) {
super(name, prenom, matricule, password, email);
}
public Employer getEmployerRelative() {
return employerRelative;
}
public void setEmployerRelative(Employer employerRelative) {
this.employerRelative = employerRelative;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}