title: Spring Data JPA: How to form a conditional query?
body: <p>Consider a table with 4 fields: id, name, age, date. Now I want to look up the Database using these fields. So that's simple, I can do:</p>
  <pre><code>@Query(&quot;select d from data d where d.name=:name and d.age=:age and d.date=:date&quot;)
  </code></pre>
  <p>But the problem is, name, age and date are optional fields, i.e age, name, the date can be null. If age is null, then I should look up the Database using name and date and if age and name are NULL, then I should look up the Database using the date alone and so on...</p>
  <p>Is it possible to achieve this in a simple way rather than forming different queries for each scenario? Because the real scenario that I am working on has 6-7 optional fields and forming different queries for each one looks damn weird.</p>