Hibernate Spatial + Postgis + Geotools - persistence failure

0

I have a problem to persist a geometric data in the database (Postgres) I read in the forums and documentation and did not find anything about it, can someone give me some help?

Libs:

pom.xml with versions

<hibernate.envers.version>4.3.11.Final</hibernate.envers.version>
<hibernate.spatial.version>4.3.1-52N</hibernate.spatial.version> 
<hibernate.validator>4.3.2.Final</hibernate.validator> 
<hibernate.em.version>4.3.11.Final</hibernate.em.version>

Entity property

@Column(name="the_geom" , columnDefinition = "Geometry", nullable = true) 
@Type(type = "org.hibernate.spatial.GeometryType")
private Geometry theGeom;

Error:

  

Can not infer an SQL type to be used for an instance of    org.postgis.PGgeometry . Use setObject() with a Types value   explicit to specify the type to use.

    
asked by anonymous 28.11.2017 / 17:07

2 answers

1

Have you set the "spring.jpa.database-platform" property for PostgisDialect in your Application.properties?

spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisDialect
    
21.02.2018 / 18:34
0

Where I work we perform theGeom persistence using native sql. Here's an example:

INSERT INTO st_teste (the_geom) VALUES (ST_GeomFromText(#conteudoTheGeo));

And in the database the field type is mapped to public.geometry .

    
28.11.2017 / 17:35