title: Hibernate query restrictions using URL key/value style parameters
body: <p>I'm using Tapestry5 and Hibernate. I'm trying to build a criteria query that uses dynamic restrictions generated from the URL. My URL context is designed like a key/value pair. </p>
  
  <p>Example </p>
  
  <pre><code>www.mywebsite.com/make/ford/model/focus/year/2009
  </code></pre>
  
  <p>I decode the parameters as followed</p>
  
  <pre><code>private Map&lt;String, String&gt; queryParameters;
  private List&lt;Vehicle&gt; vehicles;
  
      void onActivate(EventContext context) {
              //Count is 6 - make/ford/model/focus/year/2009
              int count = context.getCount();
  
              if (count &gt; 0) {
                  int i;
                  for (i = 0; (i + 1) &lt; count; i += 2) {
                      String name = context.get(String.class, i);
                      String value = context.get(String.class, i + 1);
  
                      example "make"
                      System.out.println("name " + name);
  
                      example "ford"
                      System.out.println("value " + value);
  
                      this.queryParameters.put(name, value);
                  }
              }  
  
              this.vehicles = this.session.createCriteria(Vehicle.class)
  ...add dynamic restrictions. 
          }
  </code></pre>
  
  <p>I was hoping someone could help me to figure out how to dynamically add the list of restrictions to my query. I'm sure this has been done, so if anybody knows of a post, that would be helpful too. Thanks</p>