title: How to build JPQL queries when parameters are dynamic?
body: <p>I wonder if there is a good solution to build a JPQL query (my query is too "expressive" and i cannot use Criteria) based on a filter.</p>
  
  <p>Something like:</p>
  
  <pre><code>query = "Select from Ent"
  if(parameter!=null){
     query += "WHERE field=:parameter"
  }
  if(parameter2!=null) {
     query += "WHERE field2=:parameter2"
  }
  </code></pre>
  
  <p>But i would write WHERE twice!! and the casuistic explodes as the number of parameter increases. Because none or all could be null eventually.</p>
  
  <p>Any hint to build these queries based on filters on a proper way?</p>