title: Two foreign keys as primary key
body: <p>How would I implement the following tables using hibernate annotations?</p>
  
  <p><a href="https://i.stack.imgur.com/DM6Ft.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/DM6Ft.jpg" alt="enter image description here"></a></p>
  
  <p>Current code is: <em>(stripped for brevity)</em></p>
  
  <p><strong>User</strong></p>
  
  <pre><code>@Entity
  @Table(name = "user")
  public class User implements java.io.Serializable {
      @Id
      @GeneratedValue
      public Long getId() {
          return id;
      }
  }
  </code></pre>
  
  <p><strong>SocialNetwork</strong></p>
  
  <pre><code>@Entity
  @Table(name = "social_network")
  public class SocialNetwork implements java.io.Serializable {
      @Id
      @GeneratedValue
      public int getId() {
          return id;
      }
  }
  </code></pre>
  
  <p><strong>SocialProfile</strong></p>
  
  <pre><code>@Entity
  @Table(name = "social_profile")
  public class SocialProfile implements java.io.Serializable {
      @Id
      @ManyToOne
      @JoinColumn(name="user_id")
      public User getUser() {
          return user;
      }
  
      @Id
      @ManyToOne
      @JoinColumn(name="social_network_id")
      public SocialNetwork getSocialNetwork() {
          return socialNetwork;
      }
  }
  </code></pre>
  
  <p>Obviously my code is not working correctly right now. Can anyone shed some light onto this?</p>