Search code examples
javahibernatepolygonhibernate-spatial

How to persist MultiPoligon Objects in Hibernate-Spatial and Postgis


How can i make a

com.vividsolutions.jts.geom.MultiPolygon

objects as they occur e.g. from GeoTools using Hibernate-Spatial into a Postgis database?


Solution

  • Using Hibernate Spatial 5 an example table (using the Annotations-Method) could look like:

    @Entity
    public class MultiPolygon {
    
        @Id
        private int id;
    
        @Column(columnDefinition = "geometry(MultiPolygon,4326)")
        private com.vividsolutions.jts.geom.MultiPolygon polygon;
    
        // ... Getters - setters 
    }