我正在尝试构建此Criteria Query(PostGIS函数):
st_union
(聚合)来创建子查询。point
来比较多边形的st_within
。PostGIS查询(有效):
SELECT place0_.id
FROM place place0_
WHERE st_within(place0_.location,
(
SELECT st_union(area1_.location)
FROM area area1_
WHERE (area1_.id in (10,11)))
)
ORDER BY place0_.id;
代码:
Subquery<Geometry> locationCriteriaQuery = criteriaQuery.subquery(Geometry.class);
Expression<Geometry> stUnion = locationCriteriaBuilder.function("st_union",
Geometry.class, areaLocationRoot.get("location"));
locationCriteriaQuery.select(stUnion)
.where(locationCriteriaBuilder.and(inListPredicate, inListTypePredicate));
ParameterExpression<Geometry> stUnionParameter = criteriaBuilder.parameter(Geometry.class);
Predicate predicate = criteriaBuilder.isTrue(criteriaBuilder.function("st_within",
Boolean.class, placeRoot.get("location"), stUnionParameter));
predicateMap.put(stUnionParameter, locationCriteriaQuery));
代码失败,因为我在locationCriteriaQuery
(SubquerySelection
)参数上传递了stUnionParameter
(Geometry
)。
如何将locationCriteriaQuery
的结果传递给自定义函数参数。
重新提问:
有没有办法将SubQuery Expression
传递给Criteria Builder Function
作为参数?