title: Solving a StackOverflow exception in a recursive relation
body: <p>I have a recursive relationship between entities and at the moment my rest api converts it to JSON I get a StackOverflow exception, which I totally understand. </p>
  
  <p>Jersey uses yasson as default JSON provider and I have found a solution where you can use @JsonbTransient to ignore a property in a object when serialized. My User-class has a list of Tweets and a Tweet has a user. So I added @JsonbTransient to my tweets list property in the User class.</p>
  
  <p><strong>User-class:</strong></p>
  
  <pre><code>public class User {
      ...
      @JsonbTransient
      @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      @JoinColumn(name = "user_id")
      private List&lt;Tweet&gt; tweets;
      ...
  }
  </code></pre>
  
  <p><strong>Tweet-class:</strong></p>
  
  <pre><code>public class Tweet {
      ...
      @ManyToOne
      private User user;
      ...
  }
  </code></pre>
  
  <p>I want to render a list of all tweets (from different users) whilst accessing some properties on the related user. But I want to render the user with his list of tweets also on the same page (for getting tweets count etc.). Ignoring the tweets list on the user class isn't sufficient then.</p>
  
  <p>Is there also an annotation that provides a way to serialize such a relation without completely ignoring a property on the first level, but on a deeper level. </p>
  
  <p>For instance: When you know you are in a Tweet object that has a user, then the user ignores his tweet list and when the user isn't in a tweet object his tweet list will not be ignored. Or is this simply not possible?</p>
  
  <p>How would someone tackle such a problem?</p>
  
  <p>I could of course ignore the tweets list property in user and when I want the tweets of the corresponding user I retrieve them in another call. (not to be confused with lazy loading, because I want both the data at the start)</p>
  
  <p>But my thought says that there might be a magical annotation that automatically solves this problem. Is it there?</p>
  
  <p>Thanks in advance, </p>
  
  <p>Mike</p>