0

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.

  • You are aware that Spring Boot 3.0 is still in development and hasn't released a final release yet? I doubt the issue is with Spring Boot but rather the Hibernate versions being used. – M. Deinum Sep 20 '22 at 05:44
  • Yes, but 3.0 has had multiple milestones and is scheduled for GA in November. 3.0 will use Hibernate 6 which is a big change, and also likely the source of the problem, yes. However, at this point, this should work. – Eric Murphy Sep 20 '22 at 15:42
  • For Hibernate 6 you don't need to use spatial dialects. Just using the regular postgresql dialect will suffice, as long as you add the hibernate-spatial jar to the classpath. What is the OS for the database? – Karel Maesen Sep 21 '22 at 07:40
  • @KarelMaesen I did play with the dialects to just use PostgreSQL with no effect. This is MacOS M1 CPU. – Eric Murphy Sep 27 '22 at 19:00
  • Never tested on a MacOS M1. Could you paste more of the stacktrace (esp. the parts about Hibernate Spatial) so I can better identify the problem? (I'm the main developer of Hibernate Spatial). – Karel Maesen Sep 29 '22 at 07:17
  • @KarelMaesen Please see: https://github.com/murphye/spring-boot-postgis/blob/3.0/startup.txt https://github.com/murphye/spring-boot-postgis/blob/3.0/stacktrace.txt In the startup you can see that the PostgisDialectContributor is being applied. I don't know what to make of the stacktrace information. Please keep in mind, this problem only pops up with Spring Boot 3.0. – Eric Murphy Sep 30 '22 at 02:59
  • @KarelMaesen Here is the dependency tree which also may be of interest: https://github.com/murphye/spring-boot-postgis/blob/3.0/dependency-tree.txt – Eric Murphy Sep 30 '22 at 03:13
  • @KarelMaesen If you see my answer below, I was able to get it work. You have some broken docs here (Unresolved directive). https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#spatial-types – Eric Murphy Oct 01 '22 at 17:10

1 Answers1

0

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