Hibernate Spatial PostGis column PSQLException is of type, but expression is of type bytea

In Spring Java8 boot project with hibernate-spatial and PostgresDB 9.4

    <dependency> 
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-spatial</artifactId>
        <version>5.2.10.Final</version>
    </dependency>

application.properties

spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.spatial.dialect.postgis.PostgisPG94Dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisPG94Dialect

(I also tried using PostgisPG9Dialect)

My entity has a property

...
import com.vividsolutions.jts.geom.Point;
....
@Column(columnDefinition = "Point")
private Point cityLocation;

If I save with a null value, that's fine, but if I put a value

setCityLocation(new GeometryFactory().createPoint(new Coordinate(lng, lat));

I have:

PSQLException: ERROR: column "city_location" is of type point but expression is of type bytea  You will need to rewrite or cast the expression.

In my db, I see the column definition as

type: point
column size: 2147483647
data type: 1111
num prec radix:     10
char octet length: 2147483647

I ASK FOR CROSE ... Why does this not work?

UPDATE (it still does not work, I am collecting new information)

1) I think the problem may be creating db. In my .properties applications, I also have:

spring.jpa.properties.hibernate.hbm2ddl.auto=update

so that the circuit is updated automatically using sleep mode.

2) I can successfully run the query directly on db (I use "Squirrel SQL" as a client)

update my_table set city_location = POINT(-13,23) where id = 1

and if I

select city_location from my_table where id = 1

answer

<Other>

... ...

3) "" , :

org.geolatte.geom.codec.WktDecodeException : Wrong symbol at position: 1 in Wkt: (-13.0,23.0)

4) hibernate-spaces-5.2.10.Final.jar, "geolatte" org.hibernate.spatial:

GeolatteGeometryJavaTypeDescriptor.class GeolatteGeometryType.class

5) ( Squirrel SQL client): "my_table" ( "point" city_location, ), , , java, :/p >

Exception seen during check on DB. Exception was:
ERROR: operator does not exist: point = character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

java.. , , "", , , , ...

?

+4
1

!!

, , stackoverflow, .

, db :

db

columnDefinition = "Point" @Column,

CREATE EXTENSION postgis;

db, : Postgis: ""

!

+3

Source: https://habr.com/ru/post/1684637/


All Articles