java jpa此查询返回错误
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java jpa此查询返回错误相关的知识,希望对你有一定的参考价值。
此查询返回以下错误。任何人都有任何想法???
@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
答案
这是因为你的语法有问题。您使用方括号()围绕参数。
试试这个:
@SqlQuery("SELECT * FROM employee WHERE id = :id ")
以上是关于java jpa此查询返回错误的主要内容,如果未能解决你的问题,请参考以下文章