I have a question about hibernate-spatial. (I'm using hibernate version 6.1.7.Final)
The official hibernate documentation says that MySql's St_Buffer is not supported,
@Query("""
SELECT co
FROM example AS co
WHERE st_contains(st_buffer(:center, :radius), co.point)
""")
List<CoordinateEntity> findAllWithInCircleArea(@Param("center") final Point center,
@Param("radius") final int radius);
When I wrote the code like this,
@Test
void findAllWithInCircle() {
//given
final Point point = geometryFactory.createPoint(new Coordinate(20, 10));
point.setSRID(4326);
final CoordinateEntity ce1 = repository.save(new CoordinateEntity(point));
final Point point2 = geometryFactory.createPoint(new Coordinate(40, 40));
point2.setSRID(4326);
repository.save(new CoordinateEntity(point2));
//when
final List<CoordinateEntity> allContainArea = repository.findAllWithInCircleArea(point,10000);
//then
assertSoftly(softAssertions -> {
assertThat(allContainArea).hasSize(1);
assertThat(allContainArea.get(0)).isEqualTo(ce1);
assertThat(allContainArea.get(0).getPoint().getX()).isEqualTo(20);
assertThat(allContainArea.get(0).getPoint().getY()).isEqualTo(10);
});
}
This test code works fine. Doesn't this mean that ST_Buffer is working properly?
When I run the test code, I see that the select is created just fine.
select
c1_0.id,
c1_0.point
from
example c1_0
where
st_contains(st_buffer(?,?),c1_0.point)
I am very confused right now, I was hoping someone could tell me what the X's in the hibernate documentation mean.
I've read and re-read the hibernate documentation, but I don't seem to be getting it right.