我想用hibernate对距离进行排序,但是" st_distance"不行。日志:
----- org.hibernate.QueryException:没有节点的数据类型:org.hibernate.hql.internal.ast.tree.MethodNode - [METHOD_CALL] MethodNode:'(' + - [METHOD_NAME] IdentNode:' st_distance' {originalText = st_distance} - [EXPR_LIST] SqlNode:' exprList' + - [METHOD_CALL] MethodNode:'(' | + - [METHOD_NAME] IdentNode:' POINT' {originalText = POINT} | - [EXPR_LIST] SqlNode:' exprList' | + - [DOT] DotNode:' facilitato0_.c_longitude&# 39; {propertyName =经度,dereferenceType = PRIMITIVE,getPropertyPath =经度,路径= {synthetic-alias} .longitude,tableAlias = facilitato0_,className = com.kingox.ins.dao.entity.Facilitator,classAlias = null} | | + - [IDENT] IdentNode:' {synthetic-alias}' {originalText = {synthetic-alias}} | | - [IDENT] IdentNode:'经度' {originalText = longitude} | - [DOT] DotNode:' facilitato0_.c_latitude' {propertyName = latitude,dereferenceType = PRIMITIVE,getPropertyPath = latitude,path = {synthetic-alias} .latitude,tableAlias = facilitato 0_,className = com.kingox.ins.dao.entity.Facilitator,classAlias = null} | + - [IDENT] IdentNode:' {synthetic-alias}' {originalText = {synthetic-alias}} | - [IDENT] IdentNode:'纬度' {originalText = latitude} - [METHOD_CALL] MethodNode:'(' + - [METHOD_NAME] IdentNode:' POINT' {originalText = POINT} - [EXPR_LIST] SqlNode:' exprList' + - [PARAM] ParameterNode:'?' {ordinal = 0,expectedType = null} - [PARAM] ParameterNode:'?' {ordinal = 1,expectedType = null} [select id,name,st_distance(POINT(经度,纬度),POINT(?,?))为tmpDistance
答案 0 :(得分:1)
Hibernate Spatial中的距离函数称为distance
,而不是st_distance
。
但无论如何,MySQL的Hibernate Spatial does not support distance
。
答案 1 :(得分:0)
我用过了,为我工作
StringBuffer sb = new StringBuffer();
sb.append("select a from BikeStationEntity a "
+ "order by distance (a.coordinates, :userLocation) ASC");