I'm using Hibernate Spatial in a GIS application. I have an entity class, in which one of the columns is a geometry column, as shown below:

@Table(name = "table_name")
public class Admin implements Serializable {

    private static final long serialVersionUID = 1L;

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "gid")
    private Long id;

    @Column(name = "adm1_name")
    private String adminName;

    @Column(name = "adm1_code")
    private String adminCode;

    /*private Integer adminLevel;*/
    @Column(name = "the_geom")
    @Type(type = "org.hibernatespatial.GeometryUserType")
    private Geometry geom;

    @Column(name = "pmal")
    private String pMale;

    @Column(name = "pfem")
    private String pFemale;

    public Admin() {}

    /* Getters and Setter here*/

I've done a lot of experiments, and I've eliminated hibernate configuration as the cause. I've also eliminated Spring configuration as the cause.

I think my problem may be something to do with the version of hibernate spatial I'm using; I'm using version 4.0-M1. In my earlier experiments, I realized there are some package name changes from versionn 1.x. Other details are as follows: PostGIS JDBC: version 1.3.3, Hibernate Core: version 3.6.10 FINAL, Hibernate Entity Manager: version 3.6.10 FINAL, and PostgreSQL JDBC: version 8.4-702.jdbc3

Whenever I start my server, application deployment fails with the following error:

org.hibernate.MappingException: Could not determine type for: org.hibernatespatial.GeometryUserType, at table: #table_name# for columns: #geometry_column_name#

Any idea on how I can solve this will be highly appreciated.


The issue is the renaming of the package containing GeometryUserType class in Hibernate Spatial 4.x from

org.hibernatespatial.GeometryUserType in 1.x to org.hibernate.spatial.GeometryType in 4.x. I also changed the PostGIS JDBC driver from 1.3.3 to 1.5.2.

So, the geometry property should be defined and mapped thus:

@Type(type = "org.hibernate.spatial.GeometryType")
@Column(name = "the_geom", nullable = true)
private Geometry geom;

This sorts it out for me.

| improve this answer | |
  • What of you want to use Point (or LineString) instead of Geometry class? – russellhoff Jan 29 '16 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.