spring-boothibernatespring-data-jpapostgishibernate-spatial

Error: Invalid endian flag value encountered with Hibernate 6 and Spring Boot 3


I am having some problems with Hibernate Spatial 6 with PostGIS and Spring Boot 3.0. This project I have taken and upgraded to SB 3.0 SNAPSHOT: https://github.com/murphye/spring-boot-postgis/tree/3.0

I am getting this error when I try to run a query:

Caused by: org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered.

I am setting the dialect, but supposedly with Hibernate 6, this should no longer be necessary:

database-platform: org.hibernate.spatial.dialect.postgis.PostgisPG10Dialect

Here is the column causing the issue:

    @Column(columnDefinition = "geometry(Point,4326)")
    private Point geom;

and the query:

@Query(value="SELECT * from us_cities where ST_DistanceSphere(geom, :p) < :distanceM", nativeQuery = true)

Any thoughts on what the problem may be? It was working in Spring Boot 2.5. Thank you.


Solution

  • Update: I got this working. I had to make some tweaks but the main change was using locationtech packages rather than vividsolutions. I believe this change may be required for Hibernate 6.

    I also had to use a fork of jackson-datatype-jts that works with locationtech.

    I was also able to comment out some Spring Boot config (such as database-platform) that is no longer needed with Hibernate 6.

    Code is here on the 3.0 branch: https://github.com/murphye/spring-boot-postgis/tree/3.0