title: How to retrieve an object with filtered children through JPA
body: <p>I have a specific problem I can't seem to find an answer to. I'm currently working in a Java Spring MVC environment, using Hibernate JPA.</p>
  
  <p>In this situation, simplified, you could say I have following hierarchy:</p>
  
  <pre><code>Form entity with
  @OneToMany
  List&lt;Page&gt; pages;
  
  Page entity with
  @OneToMany
  List&lt;Question&gt; questions;
  
  Question entity with
  String status;
  </code></pre>
  
  <p>Some of these questions have a status of either <em>PRODUCTION</em> or <em>ARCHIVED</em>. Simple enough, right?</p>
  
  <p>Now, what I want to do is: I want to create a JPA query, that will allow me to retrieve the Form object, but containing only those Question objects that have a status as <em>PRODUCTION</em>.</p>
  
  <p>So when I execute the query, I have a Form object, containing pages with questions. All the questions are questions that are in production, no archived ones.</p>
  
  <p>How would I go about to do this?</p>
  
  <p>EDIT: I mistakenly set a @OneToMany relation on my above example, fixed.</p>