我在使用带有 PostGIS 和 Spring Boot 3.0 的 Hibernate Spatial 6 时遇到一些问题。我已经拍摄了这个项目并升级到 SB 3.0 SNAPSHOT:https://github.com/murphye/spring-boot-postgis/tree/3.0
当我尝试运行查询时收到此错误:
Caused by: org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered.
我正在设置方言,但据说在 Hibernate 6 中,这应该不再是必要的:
database-platform: org.hibernate.spatial.dialect.postgis.PostgisPG10Dialect
这是导致问题的列:
@Column(columnDefinition = "geometry(Point,4326)")
private Point geom;
和查询:
@Query(value="SELECT * from us_cities where ST_DistanceSphere(geom, :p) < :distanceM", nativeQuery = true)
对于可能出现的问题有什么想法吗?它在 Spring Boot 2.5 中工作。谢谢你。
更新:我成功了。我必须做一些调整,但主要的改变是使用定位技术包而不是生动的解决方案。我相信 Hibernate 6 可能需要进行此更改。
我还必须使用与 locationtech 配合使用的 jackson-datatype-jts 分支。
我还能够注释掉 Hibernate 6 不再需要的一些 Spring Boot 配置(例如数据库平台)。
代码位于 3.0 分支:https://github.com/murphye/spring-boot-postgis/tree/3.0
我知道这是一个老问题,但我最近遇到了类似的问题
无效的字节序标志值
对我来说,解决方案似乎与 hibernate-core 和 hibernate-spatial 的版本相匹配(在本例中为 6.4.4.Final)。