0

I am using PostGIS Geography type in my R2DBC Repository with custom Reader but even then I am getting this error.

Cannot decode value of type io.r2dbc.postgresql.codec.Point with OID 25281

This is my build.gradle.kts

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-r2dbc")
    implementation("org.springframework.boot:spring-boot-starter-data-redis")
    implementation("org.springframework.boot:spring-boot-starter-data-redis-reactive")
    implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
    implementation("org.springframework.boot:spring-boot-starter-validation")
    implementation("org.springframework.boot:spring-boot-starter-webflux")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
    implementation("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
    runtimeOnly("org.postgresql:postgresql")
    runtimeOnly("io.r2dbc:r2dbc-postgresql")
    annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("io.projectreactor:reactor-test")
}

Entity that I am trying to load is this one.

import io.r2dbc.postgresql.codec.Point

@Table("cities")
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
data class City(@Id val id: UUID,
                @Column("city") val city: String,
                @Column("state") val state: String,
                @Column("coordinate") val coordinate: Point)

and this is my custom Reader

@ReadingConverter
class CityReader: Converter<Row, City> {
    override fun convert(source: Row): City {
        return City(
            source.get("id", UUID::class.java)!!,
            source.get("city", String::class.java)!!,
            source.get("state", String::class.java)!!,
            source.get("coordinate", Point::class.java)!!
        )
    }
}

and this is my configuration file.

@Configuration
class DatabaseConfiguration : AbstractR2dbcConfiguration() {
    override fun connectionFactory(): ConnectionFactory {
        return ConnectionFactories.get(
            ConnectionFactoryOptions.builder().option(ConnectionFactoryOptions.HOST, "localhost")
                .option(ConnectionFactoryOptions.USER, "user")
                .option(ConnectionFactoryOptions.PASSWORD, "password")
                .option(ConnectionFactoryOptions.DATABASE, "name")
                .build()
        )
    }

    @Bean
    override fun r2dbcCustomConversions(): R2dbcCustomConversions {
        return R2dbcCustomConversions(storeConversions, listOf(CityReader()))
    }
}

Is this not supported in R2DBC at all? If it is supported then how can I fix this one.

nicholasnet
  • 2,117
  • 2
  • 24
  • 46

0 Answers0