title: Hibernate Many to Many relationship Infinity loop?
body: <p><a href="https://i.stack.imgur.com/dSMjR.png" rel="nofollow noreferrer">Project Entity's Method</a></p>
  
  <pre><code>@JsonIgnore
  @ManyToMany(mappedBy = "projects")
  private List&lt;User&gt; users = new ArrayList&lt;&gt;();
  
  public List&lt;User&gt; getUsers(){
      return users;
  }
  public void setUsers(List&lt;User&gt; users){
      this.users =users;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mkXo0.png" rel="nofollow noreferrer">User Entity's Method</a></p>
  
  <pre><code> many to many relationships between users and project...
  
  @ManyToMany(fetch = FetchType.EAGER,cascade = {CascadeType.ALL})
  @JoinTable(
          name = "user_project",
          joinColumns = {@JoinColumn(name = "userid")},
          inverseJoinColumns = {@JoinColumn(name="projectid")}
  )
  private List&lt;Project&gt; projects = new ArrayList&lt;&gt;();
  
  public List&lt;Project&gt; getProjects(){
      return this.projects;
  }
  
  public void setProjects(List&lt;Project&gt; projects){
      this.projects = projects;
  }
  </code></pre>
  
  <p>I want to create a many to many relationships between a project entity and a user entity. </p>
  
  <p>I want to get all the user associated with a project when my controller calls the project controller's method. Again when I want to fetch a user I want to get all the projects associated with the user. I am building a REST web application. </p>
  
  <p>If I don't use @JsonIgnor annotation then I get a stack overflow error. </p>
  
  <p>But if I use it inside 'Project Entity' then I don't get all the users associated with it. </p>
  
  <p>Any solution? </p>