5

I'm trying to run a simple query in Hibernate Spatial 4.0 on PostgreSQL 9.3. I have a number of objects in a table with latitude/longitude values, and I'm trying to query objects that fall within a given radius of a particular latitude/longitude. The geometry values seem to be persisted without any problem, and are defined like this in my entity class:

@Column(columnDefinition = "Geometry", nullable = true)
@Type(type = "org.hibernate.spatial.GeometryType")
private Point coordinates = null;

I don't have any errors when persisting objects with the coordinates value set. However, when I run a query, I see the following Exception:

javax.servlet.ServletException: javax.servlet.ServletException: javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet

<snip />

org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered.

The query I'm running looks like this:

Query query = this.entityManager
        .createQuery(
                "SELECT v FROM MyEntity v WHERE within(v.coordinates, :filter) = true",
                MyEntity.class);
query.setParameter("filter", point);

I came across this question on StackOverflow that mentions the same error, but I'm declaring my coordinates property the same way that is mentioned in the answer and still get this error.

For the record, I've tried using PostGIS 1.5.2 and PostGIS 2.1.0. I've also tried different version of my PostgreSQL JDBC driver, from 8.4 to 9.3. Regardless of the library version I still encounter this issue.

Can anyone shed any light on what could be happening here? Is my query wrong? Is my property not defined correctly? Is there something else I should be trying? I'm completely stuck and at a loss for what could be the issue here. Any advice would be GREATLY appreciated.

  • Are any of these running on Solaris or some other old architecture? Or are you creating/manipulating any binary values? – Mintx Nov 20 '13 at 0:13
  • No, this is running on OS X Mavericks, using PostgreSQL 9.3.1 via the PostgreSQL.app package. – Shadowman Nov 20 '13 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.