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

ttisahbt  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(59)

我基本上遇到了这篇文章中描述的同样的问题: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。我的模型定义为:

import org.locationtech.jts.geom.Geometry;
// ...

@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Builder
public class DwdPoiStation {

    /** the internal database id. */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // ...

    @Column
    private Geometry geom;

    /** the height. */
    @Column
    private float height;
}

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

spring.jpa.database-platform: org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto: update
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults: false
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没有出现在我的类路径中。现在一切都像魔法一样工作。感谢卡雷尔指出这一点!

相关问题