0

I'm trying to setup a project with hibernate-spatial using postgis. Following the tutorial for hibernate-spatial 4.0-M1 I first run into the problem that the dependency postgis-jdbc-1.5.3.jar couldn't be found. Like suggested here by somebody I used the version 1.5.2 and the tutorial compiles.

But I got an error if I try to run it. I set the debug-level for hibernate to debug und stumbled upon the following problem:

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

The error is german but means, that the type 'geometry' does not exist.

If I take the create table statement and execute it in pgadmin it works find so I think that the database is setup correctly.

My Versions:

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

Thx for help

JayBee

DataNucleus
  • 15,497
  • 3
  • 32
  • 37
JayBee
  • 145
  • 1
  • 1
  • 13
  • I managed it inbetween to build a postgis-jdbc driver out of the postgis sources but the same error remains. – JayBee Jan 25 '13 at 08:58
  • OK, found the answer. I mis-interpreted the hibernate-spatial example so that I thought, that the username in the postgres jdbc url is the database name. Unfortunately postgres does not throw an error in this case but connects to the default database on the database server. This was the database 'postgres' in my case, which had no spatial extensions. Arrg. – JayBee Feb 12 '13 at 12:50

1 Answers1

0

Your Postgresql does not support geometry. You need to add postgis extension to it in order to create spatial databases. So download suitable postgis extension for your postgresql from here. Then install it in the postgresql installation folder exactly, for example (in my system) in the following path:

 C:\Program Files (x86)\OpenGeo\OpenGeo Suite\pgsql\9.1
Dariush Jafari
  • 5,223
  • 7
  • 42
  • 71