我有一个名为 Team 的@Entity
@Entity
@Table(name="projects_participants")
public class Team {
@Id`enter code here`
@GeneratedValue(strategy = GenerationType.AUTO)
@Column
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(name="participants_id")
private int participants_id;
public int getParticipants_id() {
return participants_id;
}
public void setParticipants_id(int participants_id) {
this.participants_id = participants_id;
}
/*
@CollectionOfElements
private Set<Projects> projectsParticipant;
@ManyToMany(fetch = FetchType.LAZY,mappedBy = "team")
public Set<Projects> getProjectsParticipant() {
return projectsParticipant;
}
public void setProjectsParticipant(Set<Projects> projectsParticipant) {
this.projectsParticipant = projectsParticipant;
}
*/
}
我有另一个 bean 名称项目喜欢
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(name = "projects_participants", joinColumns = {
@JoinColumn(name = "project_id") },
inverseJoinColumns = { @JoinColumn(name = "participants_id",referencedColumnName="participants_id")})
public Set<Team> getTeam() {
return team;
}
public void setTeam(Set<Team> team) {
this.team = team;
}
它工作正常,但问题是 project_participants 表具有团队表的 project_id 和 id。但我想要 Team 表的 project_id 和 Participants_id。 project_participants 表如下
参与者表为 *
最后我想要的是表project_participants应该有project_project_id和参与者ID(不是 team_id)。Thanx 提前。