title: JPA - Spring boot -@OneToMany persistence works fine but i get a strange object when returning Json object
body: <p>I have two entities <code>( Category | product )</code> with <code>@OneToMany</code> bidirectional relationship.</p>
  
  <pre><code>@Entity
  public class Category {
  
      public Category() {
          // TODO Auto-generated constructor stub
      }
  
      public Category(String name,String description) {
          this.name=name;
          this.description=description;
      }
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private long cid;
  
      private String name;
  
      private String description;
  
      @OneToMany(mappedBy="category",cascade=CascadeType.ALL, orphanRemoval=true)
      private Set&lt;Product&gt; products;
      /..getters and setter.../
  
      }
  
      @Entity
      public class Product {
      public Product() {
          // TODO Auto-generated constructor stub
      }
  
      public Product(long price, String description, String name) {
          // TODO Auto-generated constructor stub
          this.name=name;
          this.description=description;
          this.price=price;
  
      }
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private long pid;
  
      private long price;
  
      private String name;
  
      private String description;
  
      @ManyToOne  
      private Category category;
      /..getters and setters../
      }
  </code></pre>
  
  <p>in my controller I have a function /categoris that add a new category with one product,    it works great and in my database I've got a foreign category id</p>
  
  <p>But when i try to retrieve all the categories with responseBody i got a strange object exactely in category ( i want have in product, category : the category id instead of the object it's self )</p>
  
  <pre><code>public @ResponseBody Category create() {
      Category c=new Category("LIGA","messi feghouli cristiano");
  
      Product p=new Product(200,"jahd besaf","Real Madrid");
  
      if(c.getProducts()!=null){
          c.addProducts(p);
      }else{
          Set&lt;Product&gt; products=new HashSet&lt;Product&gt;();           
          products.add(p);
          c.setProducts(products);
      }
      p.setCategory(c);
  
      cDao.save(c);  pDao.save(p);        
      return c;
  }
  
  
  @RequestMapping(value="/categories",method = RequestMethod.GET)
  public @ResponseBody List&lt;Category&gt; categories() {
      return cDao.findAll();
  }
  </code></pre>
  
  <p>this is the strage object that i got :</p>
  
  <pre><code>{"cid":1,"name":"LIGA","description":"messi feghouli cristiano","products":[{"price":200,"name":"Real Madrid","description":"jahd besaf","category":{"cid":1,"name":"LIGA","description":"messi feghouli cristiano","products":[{"price":200,"name":"Real Madrid","description":"jahd besaf","category":{"cid":1,"name":"LIGA","description":"messi feghouli cristiano","products":[{"price":200,"name":"Real Madrid","description":"jahd besaf","category":{"cid":1,"name":"LIGA","description":"messi feghouli cristiano","products":
  </code></pre>