当通过spring boot JPA CrudRepository类运行时,Below查询没有从DB返回任何结果。
@Query(nativeQuery = true, value = "SELECT *,(6371 * acos(cos( radians((?2)) ) * cos( radians(latitude)) * cos(radians(longitude) - radians((?3))) + sin(radians((?2))) * sin(radians(latitude)))) as distance FROM Table_Name where service_id =(?1) HAVING distance <3 ORDER BY distance LIMIT 5;")
List<Respone> findNearByPlacesByService(Integer service, float lat,
float longg);
在控制台上检查hibernate sql查询日志时,似乎没有在查询中注入参数。日志中没有例外。
控制台日志:
Hibernate: SELECT *,(6371 * acos(cos( radians((?)) ) * cos( radians(latitude)) * cos(radians(longitude) - radians((?))) + sin(radians((?))) * sin(radians(latitude)))) as distance FROM merchant_outlet_services where service_id =(?) HAVING distance <3 ORDER BY distance LIMIT 5;