从Hibernate Query

时间:2017-03-09 10:35:14

标签: java hibernate

我的Hibernate存储库中有以下查询:

@Query("SELECT house FROM House house WHERE (6371 * acos(cos(radians((:oLat))) * cos(radians(house.lat)) * cos(radians(house.lng) - radians((:oLng))) + sin (radians((:oLat))) * sin(radians(house.lat)))) < (:dist)")
List<House> findByLatLng(@Param("oLat") Double oLat, @Param("oLng")Double oLng, @Param("dist")Double dist);

它返回了我距离原点一定距离内的房屋清单。现在,我该怎么办,还可以存储和返回(从原点到给定记录的距离)的值:

6371 * acos(cos(radians((:oLat))) * cos(radians(house.lat)) * cos(radians(house.lng) - radians((:oLng))) + sin (radians((:oLat))) * sin(radians(house.lat))))

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我不会写你的特定例子,但是这样的话:

SELECT something
  FROM (SELECT (personId * 78) AS something
          FROM people) alias
 WHERE something < 12345