Tisha
Tisha

Reputation: 857

How does a R2DBC repository work with Postgis geometries?

I had a couple of entity classes that worked with Spring Data JPA. (These entity classes are in a postgres db with postgis installed and contain geometry fields.)

However, when I switched to r2dbc, it did not work. Any pointers will be appreciated.

Error Caused by: java.lang.IllegalStateException: Required identifier property not found for class org.locationtech.jts.geom.Geometry!

@Entity
public class Place {
    @Id
    public int id;
    @Column(columnDefinition="Geometry")
    @Type(type="org.hibernate.spatial.GeometryType")    
    public com.vividsolutions.jts.geom.Point coordinates;
}

Upvotes: 3

Views: 1717

Answers (2)

mp911de
mp911de

Reputation: 18127

There's a bit more to the state of geometry and the R2DBC Postgres driver. Note that everything in this space is evolving so things may change quickly.

The R2DBC Postgres driver supports Postgres-internal geometry types (point, line, …) as of version 0.8.5. Those can be read and written through the driver types io.r2dbc.postgresql.codec.Point and so on.

The R2DBC Postgres driver was built with an extension model so external codecs can be registered with the driver to support Postgres type extensions.

The Postgis JDBC driver has received recently a feature request asking for R2DBC PostGIS support.

The final bit is Spring Data. It requires a definition over which types are driver-native types so Spring Data can pass-thru complex types instead of trying to map these. There's an open ticket to consider R2DBC Postgres' types as simple ones.

There's however no support for JTS in Spring Data as the primary focus is on the persistence model.

Upvotes: 3

Mandroid
Mandroid

Reputation: 7524

r2dbc doesn't support spatial data yet.

Upvotes: 1

Related Questions