spring-data-relational
spring-data-relational copied to clipboard
PGobject is not considered a simple type. It was before.
Converters using PGobject logs warnings
@ReadingConverter
class PGobjectToFooConverter : Converter<PGobject, Foo?> {
override fun convert(pGobject: PGobject): Foo? {
return pGobject.value?.let { objectMapper.readValue<Foo>(it) }
}
}
Warning message:
Registering converter from class to class org.postgresql.util.PGobject as writing converter although it doesn't convert to a store-supported type; You might want to check your annotation setup at the converter implementation
It seems it was added as a Simple type and then removed in this commit. Was that intended? https://github.com/spring-projects/spring-data-relational/commit/879984d2b6dee01c49c14220aa9a8460e03ad5b7#diff-39643143ab2d0d7185fb6f633054e28a2804ba993e1ae9e4e7311bdcabae7190L158
It was only removed for R2DBC since the PG* types are part of the JDBC driver and therefore not present for R2DBC.
Please provide a Minimimal Reproducable Example, preferable as a Github repository. Make sure to include the database, either as an in memory database or if that is not possible using Testcontainers.
@schauder https://github.com/blommish/spring-data-jdbc-test/blob/main/src/test/kotlin/no/blommish/BarRepositoryTest.kt#L42
2024-04-25T11:45:23.335+02:00 WARN 71844 --- [ Test worker] o.s.data.convert.CustomConversions : Registering converter from class org.postgresql.util.PGobject to class no.blommish.MyJson as reading converter although it doesn't convert from a store-supported type; You might want to check your annotation setup at the converter implementation 2024-04-25T11:45:23.335+02:00 WARN 71844 --- [ Test worker] o.s.data.convert.CustomConversions : Registering converter from class no.blommish.MyJson to class org.postgresql.util.PGobject as writing converter although it doesn't convert to a store-supported type; You might want to check your annotation setup at the converter implementation
The problem is that the simpleTypes from the dialect don't get registered with the CustomConfiguration
.
And this happens because you overwrite the method that does that: AbstractJdbcConfiguration.jdbcCustomConversions()
Instead overwrite userConverters()
.
I created a PR to that effect for your demonstrator.