首页 > 解决方案 > hibernate 混合了vividsolutions.jts Geometry 和locationtech.jts.Geometry

问题描述

在我的 JPA 实体中,我有以下内容:

import org.locationtech.jts.geom.Geometry;
....
....
@Column(name = "geometry")
    private Geometry geometry;

我正在使用 h2 gis 进行单元测试。当测试执行时,它会给出错误:

Caused by: org.h2.jdbc.JdbcSQLException: Feature not supported: "converting to class com.vividsolutions.jts.geom.Geometry"

为什么它试图映射到不同的类。

我的部门是:

<dependency>
            <groupId>org.locationtech.jts</groupId>
            <artifactId>jts</artifactId>
            <version>1.15.0</version>
            <type>pom</type>
        </dependency>
<dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.197</version>
            <scope>test</scope>
        </dependency>
<dependency>
            <groupId>org.orbisgis</groupId>
            <artifactId>h2gis</artifactId>
            <version>1.4.0</version>
            <scope>test</scope>
</dependency>

标签: hibernateh2jts

解决方案


您不能使用不兼容的 H2、H2GIS 和 JTS 版本。

H2GIS 1.4.0 需要来自 Vivid Solutions 的 H2 1.4.196 和 JTS 1.14。

H2GIS 1.5.0 需要 LocationTech 的 H2 1.4.197 和 JTS 1.15。

如果你想使用更新版本的 H2,你需要使用一些快照版本的 H2GIS。

http://www.h2gis.org/news/releases/


推荐阅读