title: How to dynamically construct query to filter the results in Spring JPA?
body: <p>I've a scenario where I have to filter the results based on the filter options provided by the user.</p>
  
  <p>Below is the Model class:</p>
  
  <pre><code>class Site{  int price;  int length; int someProp;}  
  </code></pre>
  
  <p>I've a JSP page which has filters like minPrice, maxPrice, minLength, maxLength, minSomeProp, maxSomeProp, etc.. All of these are optional. User can filter the Sites using these options. </p>
  
  <p>I want to dynamically create query based on the passed filters. If all the filters are passed then my query looks like </p>
  
  <pre><code>findByPriceLessThanAndPriceGreaterThanAndLengthLessThanAndLengthGreaterThanAndLessThanSomePropAndGreaterThanSomeProp(param1, param2,param3, param4, param5, param6);  
  </code></pre>
  
  <p>Is there any easy way to construct the query dynamically just using the passed filters?</p>