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