我正在尝试将下面的having子句转换为JPA规范,因为此处无法使用本机查询。可能吗正如您在下面看到的,我已经做了一些工作,但是不确定我是否走对了。感谢所有帮助。
SELECT
*
FROM location
HAVING (
3959 * acos (
cos ( radians(36.191577) )
* cos( radians( lat ) )
* cos( radians( lng ) - radians(44.009585) )
+ sin ( radians(36.191577) )
* sin( radians( lat ) )
)) < 10
Specification<HouseProperty> havingClause = new Specification<HouseProperty>() {
@Override
public Predicate toPredicate(Root<HouseProperty> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
Join<Property, Location> propertyLocation = root.join("location", JoinType.INNER);
cb.function("cos", Double.class,
cb.function("radians", Double.class, propertyLocation.get("lat"))
) ;
return null;
}
};
}