Issue
Hello everyone I am using SpringBoot with Mysql . I have this error when i try to show information
I have below code in my controller :
query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2
org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2
Code
@GetMapping("showdeveforma/{id}")
public String ShowDeveFormation(Model m , @PathVariable Long id)
{
Formation frm = frmreop.findById(id).get();
m.addAttribute("avis", srv.findByforma(frm));
return"ChefProjetAffichageAffectationDeveForma";
}
Solution
Your DAO method returns more than one row but you have a single value as the result type defined and not a Collection.
Answered By - Simon Martinelli