简体   繁体   English

休眠空间错误:类型“几何”不存在

[英]hibernate spatial error: type “geometry” does not exist

I want to use hibernate spatial to handle my spatial objects.I am using hibernate-spatial-4.0.1 with hibernate 4.2 . 我想使用冬眠空间来处理我的空间对象。我在hibernate 4.2使用hibernate-spatial-4.0.1 My dialect: 我的方言:

<property name="hibernate.dialect"> org.hibernate.spatial.dialect.postgis.PostgisDialect</property>

I have an Entity like this: 我有一个这样的实体:

@Entity
@DiscriminatorValue(CK.LAYER_PICTURES)
public class PicsLayerItem extends LayerItem {

   @Column(name = "place_name")
   private String placeName;

   public void setPlaceName(String name) {
       this.placeName = name;
   }

   public String getPlaceName() {
       return this.placeName;
   }


   @Type(type = "org.hibernate.spatial.GeometryType")
   @Column(name = "locations", nullable = true)
   private LineString locations;

   public LineString getLocations() {
       return locations;
   }
}

The problem that when hibernate updates schema, it faced this error: 休眠更新架构时遇到以下错误的问题:

ERROR [http-nio-8084-exec-53] org.hibernate.tool.hbm2ddl.SchemaUpdate.execute HHH000388: Unsuccessful: alter table public.tree_item add column locations GEOMETRY
ERROR [http-nio-8084-exec-53] org.hibernate.tool.hbm2ddl.SchemaUpdate.execute ERROR: type "geometry" does not exist

I guess my postgresql does not support the geomtry types. 我猜我的PostgreSQL不支持geomtry类型。 I use PgAdminIII. 我使用PgAdminIII。 It is postgis. 这是邮政。 It supports data types like polygon . 它支持数据类型,例如polygon

在此处输入图片说明

What can I do solving this problem? 我该怎么解决这个问题?
Similar question with no answer: Type geometry not found with postgis and hibernate-spatial 没有答案的类似问题: Postgis和Hibernate-Spatial找不到类型几何

Your Postgresql does not support geometry. 您的Postgresql不支持几何。 You need to add postgis extension to it in order to create spatial databases. 您需要向其添加postgis扩展名才能创建空间数据库。 So download suitable postgis extension for your postgresql from here . 因此,可以从此处为您的postgresql下载合适的postgis扩展。 Then install it in the postgresql installation folder exactly, for example (in my system) in the following path: 然后将其完全安装在postgresql安装文件夹中,例如(在我的系统中)以下路径:

 C:\Program Files (x86)\OpenGeo\OpenGeo Suite\pgsql\9.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM