Hi
I am having trouble with Wildfly 10 and Hibernate Spatial.
I created a column like this
Code:
@Column(columnDefinition="geometry(Point,4326)")
private Point locacion;
It seemed to work fine until I added data to this column. When I do this I get
Code:
Caused by: java.lang.IllegalStateException: Received object of type org.postgresql.util.PGobject
So reading tons of confusing blogs and outdated documentation I tried many things.
I found this
https://gist.github.com/bjornharrtell/3054462So I tried adding postgis-jdbc to my module.xml this showed this
Code:
Caused by: java.lang.IllegalStateException: Received object of type org.postgis.PGgeometry
I have no problem adding data or editing data with columns like that. My problem is when I want to display it, if I do something like mylocationDao.getAll();
If that column has no data(when it is null) I have no problem displaying the data.
I know it has to do with the way the libraries are set some how. This is the relevant parts of my dom
Code:
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<scope>provided</scope>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<artifactId>jta</artifactId>
<groupId>javax.transaction</groupId>
</exclusion>
<!-- Exclude SLF4j to avoid version conflicts (we have 1.6.6, this drags
in 1.6.1) -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<!-- Exclude dom4j to avoid version conflicts (we have 1.6, this drags
in 1.6.1) -->
<exclusion>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-java8</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate-validator.version}</version>
<scope>provided</scope>
</dependency>
I have add org.postgis.postgis-jdbc 1.5.3 o 1.3.3 or net.postgis.postgis-jdbc 2.1 or 2.2. Should I use net.postgis 2.X , I tried adding them to my pom.xml
Should I try adding hibernate spatial 5.1.0.Final to my wildfly as a module, if so, should I update my wildfly s hibernete from 5.0.7 to 5.1.0 Final.
It is kind of a mess
This is my persistance.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="webmapper">
<jta-data-source>java:jboss/webmapperDS</jta-data-source>
<class>ec.com.mapachedev.webmapper.model.Operativo</class>
<class>ec.com.mapachedev.webmapper.model.PuntoRuta</class>
<class>ec.com.mapachedev.webmapper.model.PuntoSector</class>
<class>ec.com.mapachedev.webmapper.model.TipoTurno</class>
<class>ec.com.mapachedev.webmapper.model.Turno</class>
<class>ec.com.mapachedev.webmapper.model.Empresa</class>
<class>ec.com.mapachedev.webmapper.model.Grupo</class>
<class>ec.com.mapachedev.webmapper.model.Ruta</class>
<class>ec.com.mapachedev.webmapper.model.Sector</class>
<class>ec.com.mapachedev.webmapper.model.Supervisor</class>
<class>ec.com.mapachedev.webmapper.model.Logger</class>
<class>ec.com.mapachedev.webmapper.model.Base</class>
<class>ec.com.mapachedev.webmapper.model.TrackRuta</class>
<class>ec.com.mapachedev.webmapper.model.UsuariosPorEmpresa</class>
<class>ec.com.mapachedev.webmapper.model.Reporte</class>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.transaction.flush_before_completion"
value="true" />
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
</properties>
</persistence-unit>
</persistence>