title: org.postgresql.util.PSQLException: ERROR: argument of WHERE must be type boolean, not type character varying
body: <p>I am trying to execute a query using parameter specified in URL directly in spring boot. 
  Ex - <a href="http://localhost:8080/users?username=test&amp;city=london&amp;" rel="nofollow noreferrer">http://localhost:8080/users?username=test&amp;city=london&amp;</a>...
  In Spring boot I am replacing and forming a PostgreSQL query 
  like that </p>
  
  <pre><code>private List&lt;Users&gt; findByQuery(String query) {
      return entityManager
             .createNativeQuery("SELECT * FROM public.user where ? ", Users.class)
             .setParameter(1, query)
             .getResultList();
  }
  </code></pre>
  
  <p>where the query would be something like that </p>
  
  <pre><code>SELECT * FROM public.user where username='test' AND City='london'
  </code></pre>
  
  <p>Its basically to implement server-side filters and we have 6 or 7 of them</p>
  
  <p>But I keep getting following error </p>
  
  <blockquote>
    <p>2018-08-29 10:55:45.832  WARN 54751 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 0, SQLState: 42804
    2018-08-29 10:55:45.833 ERROR 54751 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : ERROR: argument of WHERE must be type boolean, not type character varying
      Position: 48
    2018-08-29 10:55:45.849 ERROR 54751 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
    org.postgresql.util.PSQLException: ERROR: argument of WHERE must be type boolean, not type character varying
      Position: 48</p>
  </blockquote>