title: Direct self-reference leading to cycle exception
body: <p>I have a class; something like the following:</p>
  
  <pre><code>public abstract class ElasticSearchValue&lt;T&gt; {
  
    private Long txId;
    private Long currentTxId;
    private T previous;
  
    public Long getTxId() {
      return txId;
    }
  
    public void setTxId(Long txId) {
      this.txId = txId;
    }
  
    public Long getCurrentTxId() {
      return currentTxId;
    }
  
    public void setCurrentTxId(Long currentTxId) {
      this.currentTxId = currentTxId;
    }
  
    public Object getPrevious() {
      return previous;
    }
  
    public void setPrevious(T previous) {
      this.previous = previous;
    }
  
  }
  </code></pre>
  
  <p>And a class that extends the class above</p>
  
  <pre><code>public class DailyActivity extends ElasticSearchValue&lt;DailyActivity&gt; {
  
    Long agentId;
    Date date;
    Long success;
  
    public Long getAgentId() {
      return agentId;
    }
  
    public void setAgentId(Long agentId) {
      this.agentId = agentId;
    }
  
    public Date getDate() {
      return date;
    }
  
    public void setDate(Date date) {
      this.date = date;
    }
  
    public Long getSuccess() {
      return success;
    }
  
    public void setSuccess(Long success) {
      this.success = success;
    }
  
    @Override
    public String toString() {
      return agentId + "_" + date.toString();
    }
  
  }
  </code></pre>
  
  <p>Now, I have an object of type <code>DailyActivity</code>, and when I try to convert it into a JSON string, I get the following exception:</p>
  
  <blockquote>
    <p>Caused by: com.fasterxml.jackson.databind.JsonMappingException:
    Direct self-reference leading to cycle (through reference chain:
    com.pr.analysis.DailyActivity["previous"])</p>
  </blockquote>
  
  <p>I have looked for solution on google but the solution which I get asks to put <code>jsonIgnore</code> to previous value which is not what I intent to do. Has anyone faced the same issue? 
  Thanks</p>
  
  <p><strong>EDIT</strong>
  I know there is a cycle in the class and I am asking how to deserialize the class which has a self reference?</p>