title: JPA Self Referencing Entities
body: <p>I have a Table called User like this:</p>
  
  <pre><code>public class User
  {
      private Long userId;
      private String username;
      //Other fields;
  }
  </code></pre>
  
  <p>Now Lets say the User can have other User friends. So how do I create this relationship in JPA.</p>
  
  <p>Meanwhile I was doing this in the User Table in Database:</p>
  
  <pre><code>USER_ID 
  USERNAME
  USER_FRIENDS
  </code></pre>
  
  <p>And in the User Entity like this:</p>
  
  <pre><code>public class User
  {
      private Long userId;
      private String username;
      //Other fields;
      @OneToMany(cascade = CascadeType.ALL)
      @Column(name = "USER_FRIENDS")
      private List&lt;UserEntity&gt; friends;
  }
  </code></pre>
  
  <p>This doesn't work. So, how do I achieve this in JPA? Thanks in advance!</p>