title: Spring data JPA and parameters that can be null
body: <p>My understanding is, that with Spring data JPA I cannot have a query method to fetch all rows where a column equals a given non-null method parameter and use the same method to fetch all rows where this column is NULL when the method parameter is null.</p>
  
  <p>Is that correct?</p>
  
  <p>So I have to distinguish this in my JAVA code and I must use a separate query method explicitly asking for null values, like in the example below?</p>
  
  <pre><code>// Query methods
  List&lt;Something&gt; findByParameter(Parameter parameter);
  List&lt;Something&gt; findByParameterIsNull();
  
  ...
  
  List&lt;Something&gt; result = new ArrayList&lt;&gt;();
  
  if (parameter == null)
    result = findByParameterIsNull();
  else
    result = findByParameter(parameter);
  </code></pre>
  
  <p>That's bad, if I have 4 parameters which could be null and would have to code 16 different query methods.</p>