title: Hibernate duplicate children array when selecting
body: <p>I am having an issue with Hibernate and selecting rows that are related to other rows in the same table. I am getting the correct results but I am getting two arrays of the same data.</p>
  
  <p>For example I get this:</p>
  
  <pre><code>[
    {
      "id": 1,
      "category": "Banner",
      "childCategories": [
        {
          "id": 11,
          "category": "Flash Banner",
          "childCategories": [],
          "children": []
        },
        {
          "id": 3,
          "category": "Image Banner",
          "childCategories": [],
          "children": []
        }
      ],
      "children": [
        {
          "id": 11,
          "category": "Flash Banner",
          "childCategories": [],
          "children": []
        },
        {
          "id": 3,
          "category": "Image Banner",
          "childCategories": [],
          "children": []
        }
      ]
    }
  ]
  </code></pre>
  
  <p>When I am expecting this:</p>
  
  <pre><code>[
    {
      "id": 1,
      "category": "Banner",
      "childCategories": [
        {
          "id": 11,
          "category": "Flash Banner",
          "childCategories": [],
          "children": []
        },
        {
          "id": 3,
          "category": "Image Banner",
          "childCategories": [],
          "children": []
        }
      ]
    }
  ]
  </code></pre>
  
  <p>Here is what is in my entity to set up the relationship to the parent row and add the results to the childCategories property.</p>
  
  <pre><code>@Entity
  @Table(name = "adMediaCategory")
  public class AdMediaCategory {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      private String category;
  
      @ManyToOne(cascade = { CascadeType.ALL })
      @JoinColumn(name = "parentId")
      @JsonBackReference
      private AdMediaCategory parent;
  
      @OneToMany(mappedBy = "parent")
      @JsonManagedReference
      private Set&lt;AdMediaCategory&gt; childCategories = new HashSet&lt;&gt;();
  
      public Integer getId() {
      `enter code here`return this.id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getCategory() {
          return this.category;
      }
  
      public void setCategory(String category) {
          this.category = category;
      }
  
      public AdMediaCategory getParent() {
          return this.parent;
      }
  
      public void setParent(AdMediaCategory parentCategory) {
          this.parent = parentCategory;
      }
  
      public Set&lt;AdMediaCategory&gt; getChildren() {
          return this.childCategories;
      }
  
      public void setChildren(Set&lt;AdMediaCategory&gt; children) {
          this.childCategories = children;
      }
  }
  </code></pre>
  
  <p>Can anyone see an issue with these annotations?</p>
  
  <p>Thanks in advance!</p>