title: Select multiple fields using findByField in JPA
body: <p>I am trying to select mulitple values from a table where input can be any of the 5 columns of the table or a combination of those fields.</p>
  
  <p>In order to use findByField in JPA I have to many combinations of findByField and call them selectively by checking which field is blanks. </p>
  
  <p>Is there an easier solution to this?</p>
  
  <p>I have 5 columns in a table that I would like to query on.</p>
  
  <p>If user enters all 5 then i want to select using all 5 fields like below.</p>
  
  <pre><code>select * from table where field1 = :field1 and field2 = :field2 and field3 = :field3 and field4 = :field4 and field5 = :field5;
  
  </code></pre>
  
  <p>But if user enters only 2 fields, then I just want to query on those 2 fields like this.</p>
  
  <pre><code>select * from table where field3 = :field3 and field5 = :field5.
  </code></pre>
  
  <p>In JPA we can do <code>findByField1AndField2AndField3</code> </p>
  
  <p>But i am having for 5 different input possibilities i will have to create like 120 possibilities. </p>
  
  <p>So is there any simpler solution?</p>
  
  <p>Thank you!</p>