Hibernate Spatial 5 - GeometryType [英] Hibernate Spatial 5 - GeometryType
问题描述
将Hibernate-spatial升级到版本5.0.0.CR2后,以下声明不再起作用:
After upgrading Hibernate-spatial to Version 5.0.0.CR2 the following declaration doesn't work anymore:
@Column(columnDefinition = "geometry(Point,4326)")
@Type(type = "org.hibernate.spatial.GeometryType")
private Point position;
带有:
org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.spatial.GeometryType]
我可以看到Jar-File中不再存在该类。 GeometryType发生了什么,它是如何被替换的?还是要包含另一个jar文件?
As I can see the class doesn't exist in the Jar-File anymore. What happend to the GeometryType and how is it replaced? Or is there another jar-file to include?
编辑:澄清。我正在将Hibernate-Spatial与PostgreSQL-Postgis数据库结合使用。
For clarification. I am using Hibernate-Spatial in Combination with a PostgreSQL-Postgis database.
推荐答案
这个解决方案很容易看到。只需删除@Type注释,因此声明如下所示:
Well the solution is too easy to see. Simply delete the @Type annotation, so the declaration looks like this:
@Column(columnDefinition = "geometry(Point,4326)")
private Point position;
来源:
注意@Type注释。这告诉Hibernate,location属性是Geometry类型。 @Type注释是特定于Hibernate的,并且是唯一需要的非JPA注释。 (在Hibernate的未来版本(版本5及更高版本)中,将不再需要显式声明几何值类型的属性。)
Note the @Type annotation. This informs Hibernate that the location attribute is of type Geometry. The @Type annotation is Hibernate specific, and the only non-JPA annotation that is required. (In future versions of Hibernate (version 5 and later) it will no longer be necessary to explicitly declare the Type of Geometry-valued attributes.)
这篇关于Hibernate Spatial 5 - GeometryType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!