【问题标题】:Type geometry not found with postgis and hibernate-spatial使用 postgis 和 hibernate-spatial 找不到类型几何
【发布时间】:2013-01-09 04:47:51
【问题描述】:

我正在尝试使用 postgis 设置一个带有 hibernate-spatial 的项目。按照 hibernate-spatial 4.0-M1 的教程,我首先遇到了找不到依赖 postgis-jdbc-1.5.3.jar 的问题。就像有人在这里建议的那样,我使用了 1.5.2 版本并且教程编译了。

但是,如果我尝试运行它,就会出错。我将休眠的调试级别设置为调试并偶然发现以下问题:

DEBUG SQL -
create table Event (
    id int8 not null,
    date timestamp,
    location GEOMETRY,
    title varchar(255),
    primary key (id)
)
Hibernate:
create table Event (
    id int8 not null,
    date timestamp,
    location GEOMETRY,
    title varchar(255),
    primary key (id)
)
ERROR SchemaExport - HHH000389: Unsuccessful: create table Event (id int8 not null, date timestamp, location GEOMETRY, title varchar(255), primary key (id))
ERROR SchemaExport - FEHLER: Typ ╗geometry½ existiert nicht  Position: 94

错误是德语,但意味着“几何”类型不存在。

如果我使用 create table 语句并在 pgadmin 中执行它,它可以正常工作,所以我认为数据库设置正确。

我的版本:

postgres          - 9.0     64Bit
postgis           - 2.0.1   64Bit
hibernate-spatial - 4.0-M1
hibernate         - 4.0.0-Final
postgis-jdbc      - 1.5.2

谢谢帮助

JayBee

【问题讨论】:

  • 我在中间管理它以从 postgis 源构建一个 postgis-jdbc 驱动程序,但仍然存在相同的错误。
  • 好的,找到答案了。我误解了 hibernate-spatial 示例,因此我认为 postgres jdbc url 中的用户名是数据库名称。不幸的是,postgres 在这种情况下不会抛出错误,而是连接到数据库服务器上的默认数据库。在我的例子中,这是数据库“postgres”,它没有空间扩展。安排。

标签: hibernate postgis hibernate-spatial


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-10-03
    • 2014-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-11
    • 2021-06-28
    相关资源
    最近更新 更多