Spring框架错误:UnuniqueresultException:结果返回多个元素
我正在使用spring框架创建一个web应用程序。我现在的任务之一是,一旦触发控制器方法,就必须在后台运行异步任务的同时向用户发送电子邮件。我正在使用面向方面的编程框架。现在我面临一个问题,电子邮件功能没有被触发。我收到下面的错误消息Spring框架错误:UnuniqueresultException:结果返回多个元素,spring,aop,Spring,Aop,我正在使用spring框架创建一个web应用程序。我现在的任务之一是,一旦触发控制器方法,就必须在后台运行异步任务的同时向用户发送电子邮件。我正在使用面向方面的编程框架。现在我面临一个问题,电子邮件功能没有被触发。我收到下面的错误消息 .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected error occurred invoking async method javax.persistence.NonUniqueResultExcep
.a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected error occurred invoking async method
javax.persistence.NonUniqueResultException: result returns more than one elements
下面是我的异步方法:
@Async
@AfterReturning(pointcut="execution(* com.kontron.web.hr.controllers.a.download(..))"
+ "&& args(email, redirAttrs) ")
public void totalDownload(String email, RedirectAttributes redirAttrs) throws Exception {
}
这是向我抛出错误异常的代码:
DownloadInfo dload = dlRepo.getDownloadUsersByYear(user.getUserName(), year);
我试着采用以下方法
List<DownloadInfo> dload= dlRepo.getDownloadUsersByYear2(user.getUserName(), year);
List dload=dlRepo.getdownloadsusersbyyear2(user.getUserName(),年份);
但它仍然失败了。有人能帮我解决这个问题吗
谢谢问题与异步、aop或电子邮件无关,而是您对spring数据的使用。您键入的repo方法返回
DownloadInfo
的单个实例,但有多个实例与您的查询匹配。如果将回购的收益类型更改为列表
会发生什么?无法识别模型方法。例如,getDownloadTime()方法显示undefined。