title: spring mvc 4 Return JSON in an infinite loop
body: <p>entity :</p>
  
  <pre><code>class A{
     private int id;
     @oneToMany(mappedBy = "a")
     private List&lt;B&gt; bList;
  }
  class B{
     private int id;
     @ManToOne
     private A a;
  }
  </code></pre>
  
  <p>repository :</p>
  
  <pre><code>interfase BRepository{ 
     @Query("select b from B b where b.a.id = ?1")
     public List&lt;B&gt; getB(String id);
  }
  </code></pre>
  
  <p>controller :</p>
  
  <pre><code>private BRepository b;
  @RequestMapping("/b")
  public Object getB(){
       return b.getB(1);
  }
  </code></pre>
  
  <p>return JSON in an infinite loop .</p>
  
  <p>Use the @JsonBackReference annotation on the class A, normal results :</p>
  
  <pre><code>   class A{
     private int id;
     @oneToMany(mappedBy = "a")
     @JsonBackReference  //this property is ignored
     private List&lt;B&gt; bList;
  }
  </code></pre>
  
  <p>But when you query a class, the returned results not bList (using @JsonBackference), what can I do to return the bList properties?</p>