title: How to search using condition OR spring jpa
body: <p>I am performing a search function in mvc spring. I want to do a search on both Firstname and LastName. If I enter a string in the search box and hit enter, I will do a search in firstName if do not find it performing a search in lastName and vice versa. That means I want to enter a string and do a search for all the fields. Here is my program content.</p>
  
  <p>Employee: </p>
  
  <pre><code>@Entity
  public class Employee implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int id;
      private String firstName;
      private String lastName;
      private int age;
      private double salary;
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public double getSalary() {
          return salary;
      }
  
      public void setSalary(double salary) {
          this.salary = salary;
      }
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface EmployeeDAO extends  JpaRepository&lt;Employee,Integer&gt;{
      List&lt;Employee&gt; findEmployeeByFirstNameOrLastName(String searchName);
  
  }
  </code></pre>
  
  <p>Controller :</p>
  
  <pre><code>@RequestMapping(value = "/search")
      public ModelAndView searchByFirstName(@RequestParam String searchName) {
          ModelAndView view = new ModelAndView("showEmployee");
          return view;
      }
  </code></pre>
  
  <p>View :</p>
  
  <pre><code> &lt;div class="row"&gt;
          &lt;form method="get" action="/search"&gt;
              &lt;div class="small-3 columns"&gt;
                  &lt;input type="text" id ="txt" name="searchName" &gt;
              &lt;/div&gt;
  
              &lt;div class="small-5 columns end"&gt;
                  &lt;button id="button-id" type="submit"&gt;Search&lt;/button&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>I had run but It can't not search both firstName or LastName. How two search both firstName or lastName with one prameter</p>