英文:
Spring Hibernate MySQL Query acos() error
问题
我正在开发一个使用Hibernate的小型Spring Boot项目。我的一个仓库方法应该返回给定半径内的教师列表。然而,当我尝试用一个查询来实现这一点(请注意我对SQL完全不熟悉),我的acos()
函数会出现以下错误。以下是我的查询语句:
@Query(value = "SELECT teacher FROM teacher WHERE " +
"acos(sin(radians(latitude)) * sin(radians(lat))" +
"+ cos(radians(latitude)) * cos(radians(lat))" +
"*cos(radians(lng)) - radians(longitude))" +
"*3959 <= distance")
Iterable<Teacher> findTeachersAround(@Param("latitude") double latitude, @Param("longitude") double longitude, @Param("distance") double distance);
在这个查询中,当我将鼠标移到acos()
函数上时,会出现以下错误信息:
预期表达式、运算符、GROUP、ORDER或HAVING,但得到了'('。
英文:
I am working on a small Spring Boot project which uses Hibernate. One of my repository methods should return list of teachers in given radius. However, when I tried to accomplish this with a query (note that I am totally new to SQL) my acos()
function gives this error.
Here is my query:
@Query(value = "SELECT teacher FROM teacher WHERE " +
"acos(sin(radians(latitude)) * sin(radians(lat))" +
"+ cos(radians(latitude)) * cos(radians(lat))" +
"*cos(radians(lng)) - radians(longitude))" +
"*3959 <= distance")
Iterable<Teacher> findTeachersAround(@Param("latitude") double latitude, @Param("longitude") double longitude, @Param("distance") double distance);
In this query when I bring mouse to acos(), I get followed error message:
> expression, operator, GROUP, ORDER or HAVING expected, got '('
I tried simply writing a number inside closure, still got the same error.
专注分享java语言的经验与见解,让所有开发者获益!
评论