Hello Karel,
Thank you for your response. As you suggested, I've already dropped these
constrains in order to test.
I checked my code, the SRID is properly set on my geometry.
I've downloaded 'postgis' source and found an example using ejb3 and
Hibernate. In the GeometryType class, they use 'BinaryWriter' and
'BinaryParser' in 'nullSafeset' and 'nullSafeGet' method's.
Are you sure with the implementation of 'nullSafeSet' method?
Thank you for your response.
Suray Ph
-----Message d'origine-----
De :
[hidden email]
[mailto:
[hidden email]] De la
part de Karel Maesen
Envoyé : mercredi 12 décembre 2007 22:07
À : Hibernate Spatial Users Discussion
Objet : Re: [hibernatespatial-users] Problem inserting geometry into postgis
Hi Phillippe,
On 12 Dec 2007, at 18:10, Philippe Suray wrote:
> In order to handle these ones, I use HibernateSpatial and Postgis.
> But I am running into an issue: when I insert a row with a geometry
> column, I got a constrain violation from Postgis because my
> geometry has a different srid than the declared one stored in
> geometry_columns table.
>
> I have created my geometry column with select addgeometrycolumn
> (
) statement. If I create the column with create column
> statement, the geometry is correctly inserted into the table
> (because no constrains were set on this column).
>
That makes sense. The constraint violation is triggered by a check
constaint on the geometry column that tests for a proper srid. This
constraint is created by the "addgeometrycolumn". To resolve this you
could either drop this particular constraint, which you seem to have
done. Or by making sure that your geometries have the proper SRID by
using a JTS geometry factory that creates geometries with that SRID,
or by invoking setSRID on the geometry.
> I think to the insert statement generated by Hibernate is not
> correct, he does not use st_geometryfromtext statement.
>
> Could you confirm this behaviour? How can I correct this?
>
Hibernate Spatial doesn't use st_geometryfromtext, because it doesn't
have to. The whole idea of Hibernate Spatial is to make it possible
to just work with JTS Geometry objects. Hibernate Spatial ensures
that these JTS Geometries are properly converted to whatever objects
the database-specific JDBC driver expects for a prepared statement
that stores geometries.
If this doesn't resolve the issue, or you still have questions, just
let me know.
Regards,
Karel Maesen
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users