异常java.lang.IllegalArgumentException: Validation failed for query for method public abstract..原因和解决
程序员文章站
2022-07-15 13:30:37
...
- 使用Spring Data JPA 报java.lang.IllegalArgumentException: Validation failed for query for method public abstract …异常的一种原因和解决办法
- 报错:
java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.dao.BarDao.findByseries()!
- 代码:
@Query(value = "select series from bar b")
List findByseries();
简单的sql语句,使用了原生的sql语句,JPA在使用原生语句时,需要加上nativeQuery = true
就可解决。
- 解决后代码:
@Query(value = "select series from bar b",nativeQuery = true)
List findByseries();