title: @OneToMany relationship with non primary key Hibernate
body: <p>I have one <strong>@Entity</strong> called Team as </p>
  
  <pre><code>    @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&lt;Projects&gt; projectsParticipant;
  
      @ManyToMany(fetch = FetchType.LAZY,mappedBy = "team")
      public Set&lt;Projects&gt; getProjectsParticipant() {
          return projectsParticipant;
      }
  
  
      public void setProjectsParticipant(Set&lt;Projects&gt; projectsParticipant) {
          this.projectsParticipant = projectsParticipant;
      }
          */
  }
  </code></pre>
  
  <p>I have another bean name <strong>Projects</strong> like</p>
  
  <pre><code>@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&lt;Team&gt; getTeam() {
      return team;
  }
  
  public void setTeam(Set&lt;Team&gt; team) {
      this.team = team;
  }
  </code></pre>
  
  <p>It works fine but the problem is project_participants Table has project_id and id of Team table. But I want project_id and Participants_id of Team table.
        <strong>project_participants Table</strong> is as below</p>
  
  <p><img src="https://i.stack.imgur.com/wGIuF.jpg" alt="enter image description here"></p>
  
  <p><strong>participants table as *</strong>
  <img src="https://i.stack.imgur.com/A7Q0R.jpg" alt="enter image description here"></p>
  
  <p>Finally What I Want is table <strong>project_participants</strong> should have <strong>project_project_id</strong> and <strong>participants_id</strong> (not team_id).Thanx in advance.</p>