title: com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25 SpringBoot
body: <p>I have a couple one to many relationships in spring between my classes. And when i try to get all my data an error like infinite recursion, here is the whole error message.</p>
  <pre><code>at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25) ~[jackson-databind-2.9.6.jar:2.9.6]
  at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:727) ~[jackson-databind-2.9.6.jar:2.9.6]
  at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:719) ~[jackson-databind-2.9.6.jar:2.9.6]
  </code></pre>
  <p>i have 2 classes that are connected with each other with OneToMany Relationship</p>
  <p><strong>USER CLASS</strong></p>
  <pre><code>public class User  {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;id&quot;)
      private Long id;
      @OneToMany(mappedBy = &quot;User&quot;)
      private List&lt;Conversation&gt; Conversation;
  </code></pre>
  <p><strong>CONVERSATION CLASS</strong></p>
  <pre><code>public class Conversation {
       @Id  @GeneratedValue(strategy = GenerationType.IDENTITY)
       private Long id;
       @ManyToOne
       @JoinColumn(name = &quot;User_id&quot;)
       private User User;
  </code></pre>
  <p><strong>Results screeshot</strong></p>
  <p><a href="https://i.stack.imgur.com/6Tnxo.png" rel="nofollow noreferrer">Results screeshot</a></p>
  <p>I don't know why it happens, but maybe it is because of the relationship with the class Failure.</p>
  <p><strong>Repository Class</strong></p>
  <pre><code>@Query(nativeQuery = true, value = &quot;SELECT * FROM `conversation` WHERE 1&quot;)
  public List&lt;Conversation&gt; findAllConv();
  </code></pre>
  <p><strong>Controller class</strong></p>
  <pre><code> @Autowired
          private ConversationRepository conv;
          
          @GetMapping(&quot;/GetAllConversation&quot;)
          public List&lt;Conversation&gt; getAllConv()
          {
              return conv.findAllConv();
          }
      
  </code></pre>
  <p><strong>Full Trace</strong></p>
  <pre><code>2021-05-14 12:58:57.306 ERROR 1540 --- [nio-8020-exec-1] w.s.e.ErrorMvcAutoConfiguration$SpelView : Cannot render error page for request [/survey/GetAllConversation/] and exception [Could not write JSON: Infinite recursion (StackOverflowError); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: org.club.entities.User_$$_jvstf65_b[&quot;conversation&quot;]-&gt;org.hibernate.collection.internal.PersistentBag[0]-&gt;org.club.entities.Conversation[&quot;user&quot;]-
  </code></pre>