Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!
转自:https://blog.csdn.net/lzx925060109/article/details/40323741
1、
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceBean': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!
原因:bean类中的扩展查询方法的query语句中的sql语句存在错误。
查询语句应该为select s from Student s where s.id=?1这种样式。其中表明Stduent必须和实体类名完全相同,否则报错。
2、Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query。
原因:事务需求异常。或许是业务逻辑类为注解为@Transactional
样例:
@Repository
@Transactional
public interface StudentServiceBean extends JpaRepository<Student,Long> {
@Query("select s from Student s where s.username=?1")
public Student find(String username);
@Modifying
@Query("update Student s set s.password=?1 where s.id=?2")
public int update(String password, Long id);
}
Validation failed for query for method public abstract boxfish.bean.Student boxfish.service.StudentServiceBean.find(java.lang.String)!的更多相关文章
- Validation failed for query for method
问题原因 sql语法,使用@Query("select id, username, usersex, userphone from User where User.usersex = ?1& ...
- Hint: Fallback method 'public java.lang.String queryUserByIdFallback(java.lang.Long)' must return: User or its subclass
1.错误日志 熔断器添加错误方法返回时,报了一个 error. com.netflix.hystrix.contrib.javanica.exception.FallbackDefinitionExc ...
- 解决spring mvc 上传报错,Field [] isn't an enum value,Failed to convert value of type 'java.lang.String[]' to required type '
没有选择附件,但是点击上传按钮的时候会报错. 之前不选择文件,直接上传空文件是可以的,后来不知道改了什么就不行了. 错误信息: -- :: [http--] TRACE org.springframe ...
- Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-02-06'; nested exception is java.lang.IllegalArgumentException]解决
今天做springbook项目前端输入日期传到数据库保存报了一下错误 Whitelabel Error Page This application has no explicit mapping fo ...
- 【spring mvc】后台API查询接口,get请求,后台Date字段接收前台String类型的时间,报错default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'createDate';
后台API查询接口,get请求,后台Date字段接收前台String类型的时间筛选条件 后台接口接收 使用的实体 而createDate字段在后台实体中是Date类型 报错信息: org.spring ...
- Java 异常 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date'
查询时发送给服务器的日期的字符串格式:yyyy-MM-dd HH:mm:ss 服务器接收到日期的字符串之后,向 MySQL 数据库发起查询时,因为没有指定日期时间格式,导致字符串数据不能正确地转换为日 ...
- 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]
spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...
- spring mvc出现 Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endtime'
在使用spring mvc中,绑定页面传递时间字符串数据给Date类型是出错: Failed to convert property value of type [java.lang.String] ...
- 出错:Failed to convert property value of type 'org.apache.ibatis.session.defaults.DefaultSqlSessionFactory' to required type 'java.lang.String' for property 'sqlSessionFactoryBeanName';
出错的详细信息: 3 ERROR [http-nio-80-exec-3] org.springframework.web.servlet.DispatcherServlet - Context in ...
随机推荐
- Httpd 文件服务器的搭建
服务器信息 系统: CentOS 安装操作 安装 httpd 直接通过 yum 安装: yum install httpd 安装完成之后,可以检查版本: http 查看版本 httpd -versio ...
- spring的事务如何配置
spring的声明式事务配置: 1. <!-- 配置sessionFactory --> <bean id="sessionFactory" class=&quo ...
- 紫书 例题 9-8 UVa 1625 (滚动数组+公共字符串处理)
这题看题解看了很久,学到了挺多(自己还是太弱,唉!) (1)这道题的思路非常的巧妙.我一开始看到就觉得不好来记录开始位置以及 结束位置.但是题解换了一个思路,记录每一次开始了但还没有结束的字符有多少个 ...
- 【面试加分项】java自己定义注解之申明注解
之前的博客http://blog.csdn.net/u010590685/article/details/47029447介绍了java的注解的基本知识今天我们学习怎样使用自己定义注解. 首先我们要声 ...
- DG的数据保护模式
DG的数据保护模式 数据保护膜有三种: – Maximum protection – Maximum availability – Maximum performance Maximum protec ...
- touch---创建文件或更改文件日期
- Python day4知识回顾
# -*- coding: utf_8 _*_# Author:Vi#字典是无序的 info = { 'student001':"DIO", 'student002':" ...
- mapper提示Could not autowire. No beans of … type found?
工具及背景: IntelliJ IDEA 2016.1.3 Ultimate.spring boot, maven项目,利用mybatis 注解的方式查询mysql 在自动生成工具生成代码后,serv ...
- wpf--------------datagrid全选反选 多选进行删除操作 前后台
前台绑定 <DataGrid.Columns> <DataGridTemplateColumn > <DataGridTemplateColumn.HeaderTempl ...
- Android 控件:CheckBox
首先,在布局文件里注冊CheckBox activity_main.xml <LinearLayout xmlns:android="http://schemas.android.co ...