title: Spring JPA - Get all Child Elements
body: <p>I have the following POJOs'</p>
  
  <p>Filter ----> Filter Components </p>
  
  <pre><code>@Entity
  public class Filter {
  
              @Id
              @GeneratedValue(strategy = GenerationType.AUTO)
              private int id;
              private String name;
      //Setters and getters are not shown 
  </code></pre>
  
  <p>And I have the following child class</p>
  
  <pre><code>@Entity    
  public class FilterComponents {
          @Id
          @GeneratedValue(strategy = GenerationType.AUTO)
          private int id;
          private int component_id;
          private int component_type;
  
          @ManyToOne
          @JoinColumn(name = "filter_id")
          private Filter filter;
  //Setters and getters are not shown
  </code></pre>
  
  <p>I created a repository to query for Filters</p>
  
  <pre><code>public interface FilterRepository extends JpaRepository &lt;Filter, Long&gt; {}
  </code></pre>
  
  <p>I am calling the <code>findAll()</code> function to get all Filters. The function is working fine; however, it only returns the name and id of each filter. </p>
  
  <p><a href="https://i.stack.imgur.com/32FkE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32FkE.jpg" alt="enter image description here"></a></p>
  
  <p>Is there a way to return the corresponding Filter Components as well? I assume I can write a join query, but I have a feeling that there is a cleaner way to do it!</p>
  
  <p>Thank you  </p>