title: Following Followers in Spring
body: <p>I am trying to develop a Following Followers functionality in a Spring Boot application. i search for example and I saw this one, which made perfect sense at the beginning:</p>
  
  <p><a href="https://github.com/SoichiSumi/Twitter-Clone/blob/master/src/main/java/yoyoyousei/twitter/clone/domain/model/User.java" rel="nofollow noreferrer">https://github.com/SoichiSumi/Twitter-Clone/blob/master/src/main/java/yoyoyousei/twitter/clone/domain/model/User.java</a></p>
  
  <p>My User had a ManyToMany relation of following, like this....</p>
  
  <pre><code>@ManyToMany(fetch = FetchType.EAGER)
  @JoinTable(name = "relation",
              joinColumns = @JoinColumn(name = "user_id"),
              inverseJoinColumns = @JoinColumn(name = "following_id"))
  private List&lt;User&gt; following;
  </code></pre>
  
  <p>I developed my controllers, JSPs and tables and it works great to see which user your are following, but the problem came when I tried to  develop the Followers.</p>
  
  <pre><code>User_id  Following_id
  1       2
  1       3
  1       4
  1       6
  2       4
  2       6
  </code></pre>
  
  <ul>
  <li>User_ID=1 is following user: 2,3,4&amp;6</li>
  <li>User_ID=4 has followers: 1&amp;2</li>
  </ul>
  
  <p>How could I ask that table for the followers of user_id=4? </p>
  
  <p>I thought that I should use a FollowerService and DAO, but I realized that I do not have a bean to use it.
  The only way I think I can do it is to fetch all the table and start searching for all the appearances of a certain following_id to see with user_id is the follower.</p>
  
  <p>I can not find an easy way to do it. Do you think I should create a bean? How? Thanks</p>