0
如何添加ST_Distance(u.position,st_setsrid(st_makepoint(:LAT,:LNG),4326))到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>
当我试试这个:
@Query("""SELECT u, ST_Distance(u.position, st_setsrid(st_makepoint(:lat, :lng), 4326)) as position 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>
我得到了以下错误:
Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'ST_Distance' {originalText=ST_Distance}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[DOT] DotNode: 'driver0_.position' {propertyName=position,dereferenceType=PRIMITIVE,getPropertyPath=position,path=u.position,tableAlias=driver0_,className=com.cloudtaxi.repository.entity.Driver,classAlias=u}
| +-[ALIAS_REF] IdentNode: 'driver0_.id' {alias=u, className=com.cloudtaxi.repository.entity.Driver, tableAlias=driver0_}
| \-[IDENT] IdentNode: 'position' {originalText=position}
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'st_setsrid' {originalText=st_setsrid}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[METHOD_CALL] MethodNode: '('
| +-[METHOD_NAME] IdentNode: 'st_makepoint' {originalText=st_makepoint}
| \-[EXPR_LIST] SqlNode: 'exprList'
| +-[NAMED_PARAM] ParameterNode: '?' {name=lat, expectedType=null}
| \-[NAMED_PARAM] ParameterNode: '?' {name=lng, expectedType=null}
\-[NUM_INT] LiteralNode: '4326'