title: JPA Hibernate two foreign keys to the same table
body: <p>I've found two topics <a href="https://stackoverflow.com/questions/5754243/how-to-map-two-foreign-keys-mapping-to-the-same-primary-key-column-in-hibernate">this</a> and <a href="https://stackoverflow.com/questions/22954787/hibernate-with-two-foreign-keys-from-same-table-annotation">this</a>, but still cannot populate it to my case. I have an <code>Account</code>. I can do <code>Payments</code> from one account to another. For that purpose I want to store <code>payer_account_id</code> and <code>receiver_account_id</code> in <code>Payments</code> table. How can I map that using Annotations?
  <a href="https://i.stack.imgur.com/vTXhN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vTXhN.png" alt="enter image description here"></a></p>
  
  <pre><code>@Entity
  public class Account {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
      private Double balance;
  
      //mapping here to Payments Entity
      private ???
  
  }
  
  
  @Entity
      public class Payments {
          @Id
          @GeneratedValue(strategy = GenerationType.IDENTITY)
           private Long id;
          private Double ammount;
  
          //mapping here to Account Entity
          private Account payerAccount;
  
          //mapping here to Account Entity
          private Account receiverAccount;
  
      }
  </code></pre>