-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Mon Sep 05, 2016 11:29 am 
Newbie

Joined: Mon Sep 05, 2016 11:18 am
Posts: 2
Hi,
I am defining a PostGIS spatial table in Postgres 9.5
@Column(name = "location", columnDefinition = "Geometry(Point,4326)")
public Point location;
column.
We utilize Spring hibernate-spatial 5.2.2.Final, hibernate-core 5.2.2.Final, hibernate-entitymanager 5.2.2.Final maven dependencies.
When invoking save to hibernate, we keep receiving below error:

o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: XX000
o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: Invalid endian flag value encountered.
o.h.e.j.b.internal.AbstractBatchImpl : HHH000010: On release of batch it still contained JDBC statements.

Can anyone help?


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Thu Sep 08, 2016 9:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The example shown in the 5.2 User Guide can be found here, on GitHub.

There, I used the following Point class:

Code:
import com.vividsolutions.jts.geom.Point;


Can you validate that you're using the same Point class as well?


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Thu Sep 08, 2016 10:45 am 
Newbie

Joined: Mon Sep 05, 2016 11:18 am
Posts: 2
Thanks,
we tried it and it works. Thanks a lot!!!

martin


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Thu Sep 08, 2016 11:12 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You are welcome.


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Wed Aug 30, 2017 11:04 am 
Newbie

Joined: Wed Aug 30, 2017 10:59 am
Posts: 5
I'm running into the same problem. Although my configuration is a little bit different. I'm using Hibernate 5.1
Here are the details:

The entity class:

import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;

@Entity
public class PontodeInteresse implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;

private String descricao;

private Point ponto;

private LineString linha;

private Geometry geometry;

private Polygon poligono;

/* Getters and setters */

I can insert a Polygon from code. Everything seems to be fine:

public void criarGeometry () {
PontodeInteresse ponto = new PontodeInteresse();

GeometryFactory gf = new GeometryFactory();

LinearRing shell = gf.createLinearRing(new Coordinate[] {
new Coordinate(-43.5552982, -22.8839067), new Coordinate(-43.5556591, -22.8838402),
new Coordinate(-43.5554786, -22.8829425), new Coordinate(-43.5555869, -22.8824438),
new Coordinate(-43.5552982, -22.8839067)});
LinearRing[] holes = new LinearRing[0];
Polygon polygon = gf.createPolygon(shell, holes);
ponto.setGeometry(polygon);
colocar(ponto);
}

But, when I try to run a simple geospatial query from the method testar() (below), I get the "Invalid endian flag value encountered" error. I have already tried to use @Column and set the geo types, but got no luck. The very same error happens if I try to run this query from PgAdmin:

SELECT ST_AsGeoJSON(ST_GeomFromWKB(geometry)) from pontodeinteresse;

public void testar() {
try {
GeometryFactory gf = new GeometryFactory();
Point pontoDentro = gf.createPoint( new Coordinate(-43.5658, -22.8722) );
PontodeInteresse bairro = null;
bairro = (PontodeInteresse) entityManager.createQuery("select p from PontodeInteresse p where contains(p.geometry, :ponto) = true").setParameter("ponto",pontoDentro).getSingleResult();
if (bairro != null) {
resultado = "OK";
} else {
resultado = "ERRO";
}//if
} catch(Exception e) {
System.out.println(e.getMessage());
}//try
}

POM dependencies included:

<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-spatial</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>

The persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_2_0.xsd">
<persistence-unit name="projetoX_PU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jboss/datasources/projectNameDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
</properties>
</persistence-unit>
</persistence>

Thanks is advance


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Wed Aug 30, 2017 2:40 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
This is probably due to HHH-11086 which hasn't been fixed.


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Wed Aug 30, 2017 3:41 pm 
Newbie

Joined: Wed Aug 30, 2017 10:59 am
Posts: 5
In my case, I'm using PostgreSQL 9.6 and PostGIS 2.3. I'm stuck here. Any other ideas ? Any workaround ? Thanks


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Wed Aug 30, 2017 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Try with the PostgisPG95Dialect instead of PostgisDialect. Maybe it will work.


Top
 Profile  
 
 Post subject: Re: Postgres 9.5 Invalid endian flag value postgis
PostPosted: Mon Sep 04, 2017 10:26 pm 
Newbie

Joined: Wed Aug 30, 2017 10:59 am
Posts: 5
Sorry for the late response Vlad, but in order to follow your suggestion, I had to use Hibernate 5.2 , since the previous versions don't have the PostgrePG95Dialect. That was when my let's call it "update crusade" began.

To use Hibernate 5.2 I had to upgrade Java to version 8, then I had to upgrade JBOSS7.1.1 to Wildfly (JBOSS 7.1 won't run on Java 8)

But here I am again. Now I'm getting "Received object of type org.postgresql.util.PGobject" error.
I can insert a POINT via Hibernate, and query it using this query "select id, ST_AsText(ponto) from pontodeinteresse".
But Hibernate still can't retrieve the correct value from database. The stack trace:

java.lang.IllegalStateException: Received object of type org.postgresql.util.PGobject
at org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor.toGeometry(PGGeometryTypeDescriptor.java:123)
at org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor$2.doExtract(PGGeometryTypeDescriptor.java:87)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:235)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:231)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:222)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:296)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2840)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1735)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1661)
at org.hibernate.loader.Loader.getRow(Loader.java:1550)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:733)
at org.hibernate.loader.Loader.processResultSet(Loader.java:978)
at org.hibernate.loader.Loader.doQuery(Loader.java:936)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
at org.hibernate.loader.Loader.doList(Loader.java:2622)
at org.hibernate.loader.Loader.doList(Loader.java:2605)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2434)
at org.hibernate.loader.Loader.list(Loader.java:2429)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1339)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:483)
at org.jboss.as.jpa.container.QueryNonTxInvocationDetacher.getResultList(QueryNonTxInvocationDetacher.java:58)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.