Spring Boot Hibernate 6.3创建bytea列类型而不是几何体

ttisahbt  于 2024-01-06  发布在  Spring
关注(0)|答案(1)|浏览(169)

我基本上遇到了这篇文章中描述的同样的问题:hibernate-spatial-4.0 creates bytea column type instead of geometry
根据hibernate文档,jts Geometry对象的类型Map应该自动完成,而不需要任何额外的注解。
我使用Sping Boot 3.2,hibernate 6.3.1.Final和jts 1.19。我的模型定义为:

  1. import org.locationtech.jts.geom.Geometry;
  2. // ...
  3. @NoArgsConstructor
  4. @AllArgsConstructor
  5. @Data
  6. @Entity
  7. @Builder
  8. public class DwdPoiStation {
  9. /** the internal database id. */
  10. @Id
  11. @GeneratedValue(strategy = GenerationType.IDENTITY)
  12. private Long id;
  13. // ...
  14. @Column
  15. private Geometry geom;
  16. /** the height. */
  17. @Column
  18. private float height;
  19. }

字符串
我已经相应地设置了Hibernate方言:

  1. spring.jpa.database-platform: org.hibernate.dialect.PostgreSQLDialect
  2. spring.jpa.hibernate.ddl-auto: update
  3. spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults: false
  4. spring.jpa.properties.hibernate.default_schema: public


对于数据库,我使用kartoza/postgis:16-3.4 docker镜像。PostgreSQL jdbc驱动程序版本为42.7.1。
我错过了什么?
我尝试了另一个帖子中提供的解决方案之一(https://stackoverflow.com/a/60469891/10209352),检查了我的依赖项,并使用了最新的jts库。我还在网上搜索了其他解决方案,但甚至无法找到一个相关的问题,使用hibernate 6. x版本。由于官方文档声明不需要额外的注解,我希望我不必使用像“columnDefinition”这样的属性或像@Type这样的注解来实现这一点。这似乎是一个版本不匹配的问题。

tvokkenx

tvokkenx1#

不知何故,休眠空间jar没有出现在我的类路径中。现在一切都像魔法一样工作。感谢卡雷尔指出这一点!

相关问题