J'ai des problèmes pour intégrer ces technologies:
- Hibernate Spatial 4.0-M1
- PostGIS 2.0.2 (avec JDBC 2.0.2 compilé)
- Hibernate 4.1.1
L'erreur spécifique est:
Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.postgis.PGgeometry. Use setObject() with an explicit Types value to specify the type to use.
L'annotation d'entité est:
@NotNull
@Column(columnDefinition="Geometry")
@Type(type="org.hibernate.spatial.GeometryType")
private Point geom;
Et l'exemple de création de point est:
Location location = new Location();
WKTReader fromText = new WKTReader();
Point geom = null;
try {
geom = (Point) fromText.read("POINT(-56.2564083434446 -34.8982159791812)");
} catch (ParseException e) {
throw new RuntimeException("Not a WKT string:" + "SRID=4326;POINT(-56.2564083434446 -34.8982159791812)");
}
if (!geom.getGeometryType().equals("Point")) {
throw new RuntimeException("Geometry must be a point. Got a " + geom.getGeometryType());
}
location.setGeom(geom);
locationDAO.insert(location);
postgis
java
hibernate-spatial
gonzalomelov
la source
la source