hibernatehibernate-searchhibernate-spatial

Why I've got org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered?


I recently worl with hibernate-spatial 5 and I bumped with problem. When I'm trying to add my Geometry data to Postgres. I've got the next error on the commit transaction stage:

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause
org.postgresql.util.PSQLException: ERROR: Invalid endian flag value encountered.

My Entity looks like this, I've configured it like in previous posts with the same problem:

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "geotable")
@Indexed(index = "geoindex")
public class GeoPointModel implements Serializable {

    @Id
    @GeneratedValue
    @DocumentId
    @Column(name = "point_id")
    private Long id;
    @Field(index = Index.YES, analyze = Analyze.NO, store = Store.YES)
    @FieldBridge(impl = GeoBridge.class)
    @Column(name = "location", columnDefinition = "geometry(Point,4326)")
    private Geometry location;
}

My dependencies:

dependencies {
    implementation 'org.hibernate:hibernate-core:5.4.5.Final'
    implementation 'org.hibernate:hibernate-spatial:5.4.5.Final'
    implementation 'org.springframework:spring-orm:5.1.5.RELEASE'

    compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.1.8.RELEASE'
    compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.11.3.Final'
    compile group: 'org.apache.lucene', name: 'lucene-spatial', version: '5.5.5'
    compile group: 'com.spatial4j', name: 'spatial4j', version: '0.4.1'
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
    compile group: 'net.postgis', name: 'postgis-jdbc', version: '2.3.0'
}

Dialect:

dialect=org.hibernate.spatial.dialect.postgis.PostgisPG9Dialect

What did I lose? How it can be fixed?


Solution

  • Probably https://hibernate.atlassian.net/browse/HHH-11086 ? A workaround seems to be using Point instead of Geometry: https://forum.hibernate.org/viewtopic.php?p=2490324&sid=36d7ee961e6ff5e45e71a8aa613cb469#p2490324

    On a not-so-related note, if you're still trying to use Hibernate Search (you tagged it in this question, after all), have a look at @Spatial: https://docs.jboss.org/hibernate/search/5.11/reference/en-US/html_single/#spatial-indexing . In your case you would only have to make your GeoPointModel class implement org.hibernate.search.spatial.Coordinates and to add a @Spatial(name = "location") annotation on GeoPointModel.