title: Get single row in JPA
body: <p>How to get single row from entity in JPA?</p>
  
  <p>Table: Employee</p>
  
  <pre><code>    @Id
      private int empId;
      private String empName;
      ...    
  </code></pre>
  
  <p>JPA by default return List. I`m trying to fetch single row.</p>
  
  <p>EmployeeRepository :-</p>
  
  <pre><code>    public Employee findByEmpName(String empName);
  </code></pre>
  
  <p><strong>Another way is to do it, @Query should be use.</strong> </p>
  
  <pre><code>    @Query(value="select e from Employee e where empName = ?1 limit 1", nativeQuery=true)
      public Employee findByEmpName(String empName);
  </code></pre>
  
  <p>How can i ensure that it return single row and correct result.
  Any help appreciated.. Thanks in advance.</p>