【发布时间】:2015-12-16 11:02:01
【问题描述】:
我在使用 H2 和 GeoDB(内存中,junit)时遇到问题。
另外,使用 Hibernate 5(每个包的最新版本,包括 hibernate-spatial)和 Spring 4。
通过 id 实体进行持久化和查询效果很好。可以毫无问题地识别几何类型。
当我尝试使用地理空间函数查询数据库时出现问题,而 Hibernate 无法找到该函数:
[ERROR] 2015-12-16 11:16:15,000: org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions:129: Function "ST_CONTAINS" not found; SQL statement:
select geoentity0_.id as id1_0_, geoentity0_.location as location2_0_, geoentity0_.name as name3_0_ from GEO_ENTITY geoentity0_ where ST_Contains(geoentity0_.location, ?)=1 [90022-190]
看起来像是方言的探测。这是我正在使用的(在 persistence.xml 中):
<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.h2geodb.GeoDBDialect" />
这些是我正在使用的部门:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.190</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opengeo</groupId>
<artifactId>geodb</artifactId>
<version>0.7</version>
<scope>test</scope>
</dependency>
我做错了什么,我该如何解决?
编辑:添加h2gis
我尝试将h2gis 添加到我的部门,但没有更改错误。我也尝试用h2gis 替换geodb,结果相同。
<dependency>
<groupId>org.orbisgis</groupId>
<artifactId>h2spatial-ext</artifactId>
<version>1.2.3</version>
</dependency>
【问题讨论】:
-
也许你还需要H2GIS?
-
@ThomasMueller 我已经按照您的建议进行了尝试,并根据结果更新了问题。
标签: hibernate h2 spatial-query