Validation failed for query for method public abstract is reported when Spring Data Jpa uses @Query

Question: When using Spring Data Jpa as the persistence layer, the following error occurs when using @Query annotation:

Validation failed for query for method public abstract

Solution: This is because the nativeQuery attribute value is not explicitly set to true when using native SQL in the @Query annotation.

@Query(nativeQuery = true,value = "select * from user where id = ?")
List<User> getById(@Param("id") Integer id);

 

Guess you like

Origin blog.csdn.net/y_bccl27/article/details/112304717
Recommended