[postgis-users] Use of GeometryType does not work (yet) in my case

Jan Syryn jan.syryn at trasys.be
Tue Nov 14 06:26:27 PST 2006

Hi all,

I am trying of inserting a geometry into postgres via Hibernate by using

I build a random geometry generator for testing purposes.

My POJO looks like this:

		public class GeographicalCoverage {

			private Integer id;
			private Geometry footprint;

When I do an insert or an update manually, it works (so nothing is wrong
with the geometry itself):

   		GeographicalCoverage gc = (GeographicalCoverage) it.next();
   		String query = "update geographicalcoverage set footprint =
			+ gc.getFootprint().toString() + "', 4326) where id
= " + id + ";";

Now, I want to do it directly in Hibernate:

		GeographicalCoverage geographicalCoverage = new
		Polygon polygon = createPolygon();

and gets this error:

Caused by: org.postgresql.util.PSQLException: ERROR: new row for relation
"geographicalcoverage" violates check constraint "enforce_srid_footprint"

Upon checking the database, I see that when using the Geometry type for
'footprint', some extra checks were created because I added the footprint
column with command:

		select addgeometrycolumn
('geographicalcoverage','footprint','4326', 'POLYGON',2);

The projection was added because we store all our polygons in this
After verifying the table, PGAdmin is showing next SQL code:

		CREATE TABLE geographicalcoverage
  		  id serial NOT NULL,
  		  footprint geometry,
  		  CONSTRAINT pk_geographcoverage PRIMARY KEY (id),
  		  CONSTRAINT enforce_dims_footprint CHECK (ndims(footprint)
= 2),
  		  CONSTRAINT enforce_geotype_footprint CHECK
(geometrytype(footprint) = 'POLYGON'::text OR footprint IS NULL),
  		  CONSTRAINT enforce_srid_footprint CHECK (srid(footprint) =

So the problem is clearly the polygon does not fit the right projection when
adding by Hibernate.

Any suggestions to resolve the problem ?
What is the projection when I remove the constraints ? Or when I create a
column of type 'geometry' ?


More information about the postgis-users mailing list