title: Having conditional multiple filters in Morphia query for Mongo database
body: <p><strong>Environment : MongoDb 3.2, Morphia 1.1.0</strong></p>
  
  <p>So lets say i am having a collection of Employees and Employee entity has several fields. I need to do something like apply multiple filters <strong>(conditional)</strong> and return a batch of 10 records per request.</p>
  
  <p>pesudocode as below.</p>
  
  <pre><code>@Entity("Employee")
  Employee{
   String firstname,
   String lastName,
   int salary,
   int deptCode,
   String nationality
  }
  </code></pre>
  
  <p>and in my <code>EmployeeFilterRequest</code>i carry the request parameter to the dao</p>
  
  <pre><code>EmployeeFilterRequest{
   int salaryLessThen
   int deptCode,
   String nationality..
  }
  </code></pre>
  
  <p>Pseudoclass</p>
  
  <pre><code>class EmployeeDao{
  
  public List&lt;Employee&gt; returnList;
  
  public getFilteredResponse(EmployeeFilterRequest request){
     DataStore ds = getTheDatastore();
  
     Query&lt;Employee&gt; query = ds.createQuery(Emploee.class).disableValidation();
  
     //conditional request #1
     if(request.filterBySalary){
       query.filter("salary &gt;", request.salary);
     }
  
     //conditional request #2
     if(request.filterBydeptCode){
       query.filter("deptCode ==", request.deptCode);
     }
  
     //conditional request #3
     if(request.filterByNationality){
       query.filter("nationality ==", request.nationality);
     }
  
     returnList = query.batchSize(10).asList();
  
  /******* **THIS IS RETURNING ME ALL THE RECORDS IN THE COLLECTION, EXPECTED ONLY 10** *****/
   }
  }
  </code></pre>
  
  <p>SO as explained above in the code.. i want to perform conditional filtering on multiple fields. and even if batchSize is present as 10, i am getting complete records in the collection.</p>
  
  <p>how to resolve this ???</p>
  
  <p>Regards
  Punith</p>