title: How to do a simple username search query using JPA
body: <p>i am trying to get the user to search for a username and output the results, i think i have everything almost there i am just unsure if i am doing this correctly and using the right classes;</p>
  
  <p>currently i have in the view </p>
  
  <pre><code>&lt;p:inputText id="search" value="#{bean.userToDelete.getUsername}"  /&gt;   
                  &lt;p:commandButton value="Search" action="#{bean.searchUser}" update="group" /&gt;
  </code></pre>
  
  <p>which should allow the user to enter a search term</p>
  
  <p>this then goes to the "bean" which is a controller
  this is currently all i have </p>
  
  <pre><code>public void searchUser() {
      }
  </code></pre>
  
  <p>but in my UserService (which is in my business layer) i have</p>
  
  <pre><code>public String usernameSearch(String username) {
          List&lt;User&gt; usernameSearch = this.userFacade.usernameSearch(username);
          return "/index";
      }
  </code></pre>
  
  <p>which i think should be able to search the db ?</p>
  
  <p>however  also have a UserFacade bean with</p>
  
  <pre><code>   public List&lt;User&gt; usernameSearch(String searchString) {
          Query q = em.createQuery("SELECT u FROM USERS U WHERE u.username = :search");
          q.setParameter("search", searchString);
          return q.getResultList();
      }
  </code></pre>
  
  <p>i suppose my question is have i got all the things i need to run a search query and how can i put them all together to make it work ?</p>
  
  <p>sorry i am new to this as the method i was using to do all this turned out to be wrong and the aim is once i can understand how this works i will be able to be do more but it is just understanding how the proccess works atm</p>