Getting org.postgresql.geometric.PGpoint instead of org.postgis.PGgeometry in Hibernate Spatial

2.1k views Asked by At

I've been struggling with this for a while. Running on Tomcat 7.0.47

Relevant Entity Class snippet:

@Column(name = "geopoint", columnDefinition = "org.postgis.Geometry")
@Type(type = "org.hibernate.spatial.GeometryType")
private com.vividsolutions.jts.geom.Point geopoint;

Here are the libraries I'm using:

Hibernate Spatial 4.0-M1
postgis-jdbc 2.1.0SVN (used 1.5.3 before, same issue.)
Hibernate 4.2.7

Datasource Info

Datasource = org.apache.tomcat.jdbc.pool.DataSource
Driver Class Name = org.postgis.DriverWrapper
JDBC URL Beginning = jdbc:postgresql_postGIS:

The DB is PostgreSql 9.3 on Amazon RDS with PostGIS installed. The column geopoint is of type "point". I created this table using PgAdminIII

Hibernate Session Factory props

 <prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>
 <prop key="hibernate.dialect">org.hibernate.spatial.dialect.postgis.PostgisDialect</prop>
 <prop key="hibernate.showsql">true</prop>

I've debugged the code to see that the JDBC seems to be returning PGPoint. PGGeometryValueExtractor.toJTS(Object) receives a PGPoint. It seems Hibernate Spatial intends for it to be a org.postgis.Geometry or org.postgis.PGGeometry object.

Any help would be appreciated.

1

There are 1 answers

2
Craig Ringer On BEST ANSWER

point is a built-in PostgreSQL core type, not a PostGIS type.

I think you want the column type to be geometry if you're going to work with PostGIS. Try changing the column type; if you then store PostGIS points in it, it should behave as expected.