Spatial + Postgis + Geotools Hibernate - Persistence Failure

Asked

Viewed 200 times

0

I have a problem to persist a geometric data in the database (Postgres) I gave a read on the forums and documentation and found nothing about it, someone can give me a 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>

Ownership of the entity

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

Error:

You cannot 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 be used.

2 answers

1

You have set the "spring.jpa.database-Platform" property to Postgisdialect in your Application.properties?

spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisDialect

0

Where I work we perform the persistence of theGeom using sql Native. See an example:

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

And in the bank the field guy is mapped as public.Geometry.

  • I would like to use the lib of Hibernate Spatial to make the persistence, I even managed to make the persistence after having created a new project with the same dependencies inclusive, but I can’t do in my application because it points out this error. But thanks, it might be a good alternative.

  • Bacana Diego. Recently we took Hibernate out of the application. When you find the solution, post here! :)

  • I used what you suggested, but I’m trying to figure out why, as soon as I can!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.