SpringBoot使用Jpa查询报错

2019-09-04 11:37:43,951 ERROR (org.hibernate.hql.internal.ast.ErrorCounter:55)- line 1:9: unexpected token: *


@Query(value = “select * from table”)
public int test();

上面是报错,下面是sql语句。

之前也遇到过这个问题,再遇到又忘了,开贴记录一下:

下面是解决方案

@Query(value = “select * from table”, nativeQuery = true)
public int test();

加上 nativeQuery = true即是启用原生sql。

不加的情况下sql语句应该是从from开始的,如下:

@Query(value = “from table”)
public int test();

猜你喜欢

转载自blog.csdn.net/qq_33247435/article/details/100536733