Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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