com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:在“option sql\u select\u limit=default”附近的sql语法中有错误

iovurdzv  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(347)

此查询返回以下错误。有人知道吗???

@SqlQuery("SELECT * FROM employee WHERE id = (:id) ")
Employee getByid(@Bind("id") Integer id);

结果:

2018-08-29 11:12:19.532 ERROR 9736 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    :
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; 
nested exception is org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: Could not clean up 
[statement:"SELECT * FROM employee WHERE id = (:id) ", located:"SELECT * FROM employee WHERE id = (:id) ", 
rewritten:"SELECT * FROM employee WHERE id = (?) ", arguments:{ positional:{}, named:{id:1}, finder:[]}]] with root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 
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 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1
643ylb08

643ylb081#

这是因为你的语法有问题。您的参数用括号()括起来。
试试这个:

@SqlQuery("SELECT * FROM employee WHERE id = :id ")

相关问题