title: Spring JPA Repository Custom Query
body: <p>This custom query works(this is just a basic query to illustrate the problem):</p>
  
  <pre><code>public interface BookQueryRepositoryExample extends Repository&lt;Book, Long&gt; {
      @Query(value = "select * from Book b where b.name=?1", nativeQuery = true)
      List&lt;Book&gt; findByName(String name);
  }
  </code></pre>
  
  <p>but I need another custom query where the <code>where</code> clause will be constructed dynamically before calling the method.</p>
  
  <pre><code>public interface BookQueryRepositoryExample extends Repository&lt;Book, Long&gt; {
      @Query(value = "select * from Book b where ?1", nativeQuery = true)
      List&lt;Book&gt; findByWhatever(String qry);
  }
  </code></pre>
  
  <p>But I am not able to make it work. Is there any workaround?</p>
  
  <p>Updated: 6/16/2017</p>
  
  <p>Just want to mention this that the field I am searching is 'denormalized' form. The values can look like these(below). So my query has a series of like statements</p>
  
  <p>Sample 1:</p>
  
  <pre><code>name:John Smith;address1:123 Xyz St;city:New York;zip:12345;country:USA;id:ABC1234;email:js@abc.com;
  </code></pre>
  
  <p>Sample 2:Rearranged</p>
  
  <pre><code>address1:123 Xyz St;zip:12345;email:js@abc.com;name:John Smith;country:USA;id:ABC1234;city:New York;
  </code></pre>
  
  <p>Sample 3:Missing strings/text</p>
  
  <pre><code>zip:12345;email:js@abc.com;name:John Smith;id:ABC1234;city:New York;
  </code></pre>