我最近遇到了一个我无法控制的问题。从我的grails应用程序执行查询时,我得到以下异常:
No data type for node: org.hibernate.hql.internal.ast.tree.AggregateNode
+-[AGGREGATE] AggregateNode: 'MAX'
| \-[METHOD_CALL] MethodNode: '('
| +-[METHOD_NAME] IdentNode: 'distance_weight' {originalText=distance_weight}
| \-[EXPR_LIST] SqlNode: 'exprList'
| +-[NAMED_PARAM] ParameterNode: '?' {name=latitude, expectedType=null}
| +-[NAMED_PARAM] ParameterNode: '?' {name=longitude, expectedType=null}
| +-[DOT] DotNode: 'place3_.location_latitude' {propertyName=latitude,dereferenceType=PRIMITIVE,getPropertyPath=location.latitude,path=p.location.latitude,tableAlias=place3_,className=gibbons5.l10n.Place,classAlias=p}
...
我正在尝试执行的查询看起来像这样(纬度和经度被传递给executeQuery调用):
SELECT MAX(distance_weight(:latitude, :longitude, p.location.latitude, p.location.longitude)) AS distance_weight, MIN(distance(:latitude, :longitude, p.location.latitude, p.location.longitude)) AS distance
FROM Activity AS a
LEFT JOIN a.events AS e
LEFT JOIN e.place AS p
distance和distance_weight存储在mysql数据库中的函数,用于计算位置之间的距离并给它们一个权重:
CREATE FUNCTION `distance`(deg_lat1 FLOAT, deg_lng1 FLOAT, deg_lat2 FLOAT, deg_lng2 FLOAT) RETURNS FLOAT
DETERMINISTIC
BEGIN
...
和
CREATE FUNCTION `distance_weight`(deg_lat1 FLOAT, deg_lng1 FLOAT, deg_lat2 FLOAT, deg_lng2 FLOAT) RETURNS INT
DETERMINISTIC
BEGIN
...
每个活动都可以有多个活动,每个活动都有自己的位置(纬度/经度)。
我在做什么w?rong?每个想法都受到高度赞赏!!