【问题标题】:hibernate spatial error: type "geometry" does not exist休眠空间错误:类型“几何”不存在
【发布时间】:2015-01-31 14:29:17
【问题描述】:

我想使用休眠空间来处理我的空间对象。我正在使用hibernate-spatial-4.0.1hibernate 4.2。我的方言:

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

我有一个这样的实体:

@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;
   }
}

hibernate更新schema时遇到这个错误的问题:

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

我猜我的 postgresql 不支持几何类型。我使用 PgAdminIII。它是postgis。它支持polygon 等数据类型。

我能做些什么来解决这个问题?
没有答案的类似问题:Type geometry not found with postgis and hibernate-spatial

【问题讨论】:

    标签: java hibernate geometry hibernate-mapping postgis


    【解决方案1】:

    您的 Postgresql 不支持几何。您需要添加postgis 扩展名才能创建空间数据库。因此,请从here 为您的 postgresql 下载合适的 postgis 扩展。然后将其安装在postgresql安装文件夹中,例如(在我的系统中)如下路径:

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

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 2011-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-05
      • 2012-06-26
      相关资源
      最近更新 更多