Spring 在hibernate中选择as

Spring 在hibernate中选择as,spring,hibernate,kotlin,Spring,Hibernate,Kotlin,如何将ST_距离(u.position,ST_setrid(ST_makepoint(:lat,:lng),4326))添加到Hibernate中的select语句中 @Query("""SELECT u FROM Driver u ORDER BY ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326)) """) fun findNearest(@Param("lat") lat: Double,

如何将ST_距离(u.position,ST_setrid(ST_makepoint(:lat,:lng),4326))添加到Hibernate中的select语句中

@Query("""SELECT u FROM Driver u
    ORDER BY ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326))
""")
fun findNearest(@Param("lat") lat: Double,
                @Param("lng") lng: Double): List<Driver>

您可以使用本机查询而不是HQL/JPQL查询

@Query(value = "SELECT * FROM Driver ORDER BY ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326))",
       nativeQuery =  true)

您可以使用本机查询而不是HQL/JPQL查询

@Query(value = "SELECT * FROM Driver ORDER BY ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326))",
       nativeQuery =  true)
@Query(value = "SELECT * FROM Driver ORDER BY ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326))",
       nativeQuery =  true)