title: dynamically Search Query in HQL with optional Parameter?
body: <p>i am developing an application in which i need search functionality, i want to write HQL query that dynamically create according to parameters.
  Currently i have 4 parameters, while searching all parameters are required or 1 or 2 or 3 parameters required according to how user want to searchs.</p>
  
  <pre><code>public List&lt;Plot&gt; fetchSearchedPlots(int plotType, String plotSize, String min, String max)
      {
          Session session = sessionFactory.getCurrentSession();
          List&lt;Plot&gt; searchedLists = new ArrayList&lt;Plot&gt;();
          String query = "FROM Plot where type = ? and size = ? and price &gt;= ? and price &lt;= ?";
          searchedLists = (List&lt;Plot&gt;)session.createQuery( query )
                  .setInteger( 0, plotType )
                  .setString( 1, plotSize )
                  .setString( 2, min )
                  .setString( 3, max ).list();
          return searchedLists;
      }
  </code></pre>
  
  <p>this is my general query for all 4 parameters, now i have to write a search query in which i use multiple optional parameters, How to make this query with optional parameters? kindly convert my query to dynamically optional parameters query ? 
  Thanks</p>