title: How to map a table in Spring Data JPA that has 2 columns referencing the same table
body: <p>I have a table that has 2 fields (pseudonymProfile and realProfile) that both join to the same table. When I try to do the mapping as shown below, I run into an error because the 2 fields use the same name (profile_id) in their @JoinColumn annotation. I'm under the impression that when defining a join column, I need to specify the name as &lt;jointable_primarykeyofjointable&gt; in order for spring boot to correctly do the join, but in this case they have the same name and that causes the error. Can someone help me see what I am missing? Thanks!</p>
  <pre><code>@Entity
  @Table(name = &quot;book&quot;)
  public class Book {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = &quot;id&quot;)
      private UUID id;
  
      @Column(name = &quot;title&quot;)
      private String title;
  
      @ManyToOne
      @JoinColumn(name = &quot;profile_id&quot;)
      private Profile pseudonymProfile;
  
      @ManyToOne
      @JoinColumn(name = &quot;profile_id&quot;)
      private Profile realProfile;
  }
  </code></pre>