0

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.

1 Answer 1

0

The documentation is not up-to-date.

I checked the code, and st_buffer is supported. So your code is fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.