是否可以在@Formula注释中使用在实际JPA方法中定义的@Param ?
假设这是我的公式注释,用于计算Postgre中两点之间的距离。
@Formula("(SELECT point(:lat, :lon) <@> (point(clubAddress.longitude, clubAddress.latitude)\:\:point) FROM club_address clubAddress WHERE clubAddress.id = id)")
这是实际的方法
List<ClubAddress> getClubAddressClosestBy(@Param("lat") double latitude, @Param("lon") double longitude);
当使用这个Spring抱怨,我没有使用Param在实际的查询,这是真的。有没有一种"欺骗"的方法?想起来了吗?
不,@Formula
是不可参数化的。对不起。