title: StackOverflowError: null when doing a get request
body: <p>I'm having a problem when i try to do a get request to my /users endpoint, instead of returning what i want to, returns this error below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>2018-07-07 17:00:06.636 ERROR 294108 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"]-&gt;org.hibernate.collection.internal.PersistentSet[0]-&gt;io.union.restapi.domain.User["group"]-&gt;io.union.restapi.domain.Group["users"])] with root cause
  
  java.lang.StackOverflowError: null
   at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_171]
   at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~</code></pre>
  </div>
  </div>
  </p>
  
  <p>my endpoint method:</p>
  
  <pre><code> @Override
      public ResponseEntity&lt;List&lt;M&gt;&gt; findAll() {
          List&lt;M&gt; models = repository.findAll();
  
          if(models == null || models.isEmpty()){
              return ResponseEntity.noContent().build();
          }
  
          return ResponseEntity.ok(models);
      }
  </code></pre>
  
  <p>User model:</p>
  
  <pre><code>@Entity
  @Table(name = "UN_USERS")
  public class User extends AbstractModel {
  
      @Column(name = "USERNAME", unique = true)
      private String username;
  
      @Column(name = "UUID")
      private String uuid;
  
      @Column(name = "COINS")
      private long coins;
  
      @Column(name = "TOKENS")
      private long tokens;
  
      @ManyToOne
      @JoinColumn(name = "GROUP_ID", nullable = true)
      private Group group;
  
      //getters &amp; setters... 
  }
  </code></pre>
  
  <p>Group model:</p>
  
  <pre><code>@Entity
  @Table(name="UN_GROUPS")
  public class Group extends AbstractModel{
  
      private String prefix;
  
      @OneToMany(mappedBy = "group")
      private Set&lt;User&gt; users;
  
      @ManyToMany(mappedBy = "groups")
      private Set&lt;Permission&gt; permissions;
  }
  </code></pre>
  
  <p>What could possible give this error and how can i fix?</p>