Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Spatial 5 - GeometryType

After upgrading Hibernate-spatial to Version 5.0.0.CR2 the following declaration doesn't work anymore:

@Column(columnDefinition = "geometry(Point,4326)") @Type(type = "org.hibernate.spatial.GeometryType") private Point position; 

with an:

org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.spatial.GeometryType] 

As I can see the class doesn't exist in the Jar-File anymore. What happend to the GeometryType and how is it replaced? Or is there another jar-file to include?

Edit: For clarification. I am using Hibernate-Spatial in Combination with a PostgreSQL-Postgis database.

like image 671
Denis Lukenich Avatar asked Jul 15 '15 20:07

Denis Lukenich


1 Answers

Well the solution is too easy to see. Simply delete the @Type annotation, so the declaration looks like this:

@Column(columnDefinition = "geometry(Point,4326)") private Point position; 

Source:

Note the @Type annotation. This informs Hibernate that the location attribute is of type Geometry. The @Type annotation is Hibernate specific, and the only non-JPA annotation that is required. (In future versions of Hibernate (version 5 and later) it will no longer be necessary to explicitly declare the Type of Geometry-valued attributes.)

like image 81
Denis Lukenich Avatar answered Oct 04 '22 17:10

Denis Lukenich