title: Java Play Framework finder with if else query
body: <p>I wrote the following piece of code to do selective queries, but it doesn't seem to be working.</p>
  
  <pre><code>public static List&lt;Item&gt; selectBy(String name, String attr) {
      Query&lt;Item&gt; find = myFinderInstance;
      if (name != null) {
          find.where().eq("name", name);
      }
      if (attr != null) {
          find.where().eq("attr", attr);
      }
  
      return find.findList();
  }
  </code></pre>
  
  <p>Basically I want the query to be able to work together. Either only by name, only by attribute or both. But with only 1 function.</p>
  
  <p>Is this not possible or am I doing it wrong?</p>