如何从与 @ManyToMany 映射注释一起映射的两个实体中添加结果表中的其他列?
我有两个课程:
package com.rachid.jpa;
import java.io.Serializable;
import java.lang.Integer;
import java.lang.String;
import java.util.Collection;
import java.sql.Date;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Project
*
*/
@Entity
@Table(name="PROJECT")
public class Project implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer idProj;
private String projectName;
private Date startDate;
private Date endDate;
@ManyToMany(mappedBy="projects")
private Collection<Employee> employees;
private static final long serialVersionUID = 1L;
@OneToOne
@JoinColumn(name="matriculeChef")
private Employee chef;
public Project() {
super();
}
public Integer getIdProj() {
return this.idProj;
}
public void setIdProj(Integer idProj) {
this.idProj = idProj;
}
public String getProjectName() {
return this.projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public Collection<Employee> getEmployees() {
return employees;
}
public void setEmployees(Collection<Employee> employees) {
this.employees = employees;
}
public Employee getChef() {
return chef;
}
public void setChef(Employee chef) {
this.chef = chef;
}
}
和
package com.rachid.jpa;
import java.io.Serializable;
import java.lang.Integer;
import java.util.Collection;
import javax.persistence.*;
/**
* Entity implementation class for Entity: Employee
*
*/
@Entity
@Table(name="EMPLOYEE")
public class Employee implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer idEmp;
@Embedded
private Personne personne;
@ManyToMany
@JoinTable(name="EMP_PROJ",
joinColumns = @JoinColumn(name="EMP_ID"),
inverseJoinColumns = @JoinColumn(name="PROJ_ID"))
private Collection<Project> projects;
@ManyToOne
@JoinColumn(name="matriculeChef")
private Employee chef;
@OneToMany(mappedBy="chef")
private Collection<Employee> manaedEmployees;
@OneToOne(mappedBy="employee")
private User user;
@OneToOne(mappedBy="chefEntite")
private Entite entite;
@OneToOne(mappedBy="chef")
private Project projet;
@OneToMany(mappedBy="employee")
private Collection<Conge> conges;
@ManyToOne
@JoinColumn(name="idEntite")
private Entite entiteTravail;
@ManyToMany
@JoinTable(name="EMP_FORM",
joinColumns = @JoinColumn(name="EMP_ID"),
inverseJoinColumns = @JoinColumn(name="FROM_ID"))
private Collection<Formation> formations;
private String fonction;
private static final long serialVersionUID = 1L;
public Employee() {
super();
}
public Integer getIdEmp() {
return this.idEmp;
}
public void setIdEmp(Integer idEmp) {
this.idEmp = idEmp;
}
public Collection<Project> getProjects() {
return projects;
}
public void setProjects(Collection<Project> projects) {
this.projects = projects;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Entite getEntite() {
return entite;
}
public void setEntite(Entite entite) {
this.entite = entite;
}
public Project getProjet() {
return projet;
}
public void setProjet(Project projet) {
this.projet = projet;
}
public Collection<Conge> getConges() {
return conges;
}
public void setConges(Collection<Conge> conges) {
this.conges = conges;
}
public Entite getEntiteTravail() {
return entiteTravail;
}
public void setEntiteTravail(Entite entiteTravail) {
this.entiteTravail = entiteTravail;
}
public Collection<Formation> getFormations() {
return formations;
}
public void setFormations(Collection<Formation> formations) {
this.formations = formations;
}
public Personne getPersonne() {
return personne;
}
public void setPersonne(Personne personne) {
this.personne = personne;
}
public Employee getChef() {
return chef;
}
public void setChef(Employee chef) {
this.chef = chef;
}
public Collection<Employee> getManaedEmployees() {
return manaedEmployees;
}
public void setManaedEmployees(Collection<Employee> manaedEmployees) {
this.manaedEmployees = manaedEmployees;
}
public String getFonction() {
return fonction;
}
public void setFonction(String fonction) {
this.fonction = fonction;
}
}
我需要在结果表EMP_PROJ中添加两列
感谢帮助