【发布时间】:2018-08-29 03:21:39
【问题描述】:
此查询返回以下错误。有人知道吗???
@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
【问题讨论】:
-
不。那不是 JPA API。请从问题中删除
jpa标签 -
堆栈跟踪是否完整?所以,如果
Employee被映射,idk,但您可以尝试扩展选择列列表并通过@RegisterMapper(EmployeeMapper.class)将列映射到bean。 -
这个已经添加了。 [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]:Servlet.service() 用于路径 [] 上下文中的 servlet [dispatcherServlet] 引发异常 [请求处理失败;嵌套异常是 org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException:无法清理 [语句:“SELECT * FROM employee WHERE id = :id”,位于:“SELECT * FROM employee WHERE id = :id”,重写: "SELECT * FROM employee WHERE id = ?", arguments:{ positional:{}, named:{id:1}, finder:[]}]] 根本原因
-
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“OPTION SQL_SELECT_LIMIT=DEFAULT”附近使用正确的语法
-
在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_171] 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_171 ] 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_171] 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_171]