小编Ami*_*our的帖子

Spring Boot 非唯一结果异常

大家好,我正在将 SpringBoot 与 Mysql 一起使用。当我尝试显示信息时出现此错误

我的控制器中有以下代码:

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
Run Code Online (Sandbox Code Playgroud)

代码

 @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";
 }
Run Code Online (Sandbox Code Playgroud)

mysql spring hibernate controller spring-boot

2
推荐指数
1
解决办法
7361
查看次数

标签 统计

controller ×1

hibernate ×1

mysql ×1

spring ×1

spring-boot ×1