springData之JPA问题记录

springboot版本:

2.2.6.RELEASE

使用@Query语句编译不通过,

 @Query("from Student where name like ?")
    List findByZheGe(String name);

启动更是会抛异常:

Caused by: java.lang.IllegalArgumentException: JDBC style parameters (?) are not supported for JPA queries.

百度了很多,几乎都是说加个index,即改造成这样:

"from Student where name like ?1"

我试了一下,还是不行,可能版本更新了吧。
接着我尝试了一下,把from后面的实体类改成数据库中的表名,问题解决:

@Query("from t_student where name like ?1")
    List findByZheGe(String name);

搞不懂呀,开发者为啥这样设计,本来hibernate就是根据对象来映射,这又换成表名查询了。

你可能感兴趣的:(springData之JPA问题记录)