Use Point type with PostgreSQL and JPA/Hibernate

INSTALL THE POSTGIS EXTENSIONS IN YOUR DATABASE.

The error you are encountering is because you have not installed anything on your database that Hibernate can relate to. It's postgres that is complaining, viz:

org.postgresql.util.PSQLException: Unknown type geometry.

Your annotations and configuration say they have a dependency on PostGIS:

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

So basically you are trying to use an unsupported configuration.

PostgreSQL does not come with all of the possible data types anyone ever thought of, the way Oracle does. So when Hibernate says "I want a 'geometry' PostgreSQL just says "what's a geometry?" PostgreSQL is very extensible so that's what the PostGIS people did - they built an extension. Anyone can install it or run completely without it. The only problem it causes is when someone expects it in the out-of-the-box database rather than it being an add-on.

I suppose you might try to reverse-engineer the PostgreSQL data types and compile them in your database. Geometry is a master superclass for PostGIS, in Java at least and it looks the same in the database. I just don't see why you would set up a configuration when you won't ever get anyone to support it.

@bluish does this help?


You should try to have the type in your db as Geometry, I also haven't managed to do it with mySQL. Geometry works as fine for points..