报错:check the manual that corresponds to your MySQL server version for the right syntax

mysql数据库中建了order表,dao层OrderDAO继承了JpaRepository,想直接用其findAll()方法来取出order表的数据。结果一调用此方法控制台就报错:

2020-05-20 16:29:39.338  WARN 3964 --- [io-8888-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1064, SQLState: 42000
2020-05-20 16:29:39.357 ERROR 3964 --- [io-8888-exec-10] o.h.engine.jdbc.spi.SqlExceptionHelper   : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order order0_' at line 1
2020-05-20 16:29:40.132  WARN 3964 --- [io-8888-exec-10] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet]

java实体类的字段和数据表的也一致。

最终看了check the manual that corresponds to your MySQL server version for the right syntax错误

说是表名order和mysql的关键字冲突了,这就是为什么报语法错误的原因。把表名order改为t_order就好了。

你可能感兴趣的:(开发错误汇总)