I'm using
spring-boot-starter-data-r2dbc 3.1.4
r2dbc-postgresql 1.0.2.RELEASE
I've
- created
TYPE MY_ENUM AS ENUM
- created
MyEnumConverter extends org.springframework.data.r2dbc.convert.EnumWriteSupport<MyEnum>
as a@WritingConverter
and registerd it withorg.springframework.data.r2dbc.convert.R2dbcCustomConversions
- Explicitly mapped
private MyEnum myEnum
into the 'entity mapping' - persisted a freshly created entity via
org.springframework.data.repository.reactive.ReactiveCrudRepository#save
And got the following error
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Cannot encode parameter of type MyEnum
Caused by: java.lang.IllegalArgumentException: Cannot encode parameter of type MyEnum
at io.r2dbc.postgresql.codec.DefaultCodecs.encodeParameterValue(DefaultCodecs.java:290) ~[r2dbc-postgresql-1.0.2.RELEASE.jar:1.0.2.RELEASE]
at io.r2dbc.postgresql.codec.DefaultCodecs.encode(DefaultCodecs.java:264) ~[r2dbc-postgresql-1.0.2.RELEASE.jar:1.0.2.RELEASE]
at io.r2dbc.postgresql.PostgresqlStatement.bind(PostgresqlStatement.java:108) ~[r2dbc-postgresql-1.0.2.RELEASE.jar:1.0.2.RELEASE]
at io.r2dbc.postgresql.PostgresqlStatement.bind(PostgresqlStatement.java:59) ~[r2dbc-postgresql-1.0.2.RELEASE.jar:1.0.2.RELEASE]
...
The configuration to R2DBC was done entirely by Spring Boot Auto Config and I do not want to move away from that. Specifically org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations.PoolConfiguration.PooledConnectionFactoryConfiguration#connectionFactory
I want to keep the auto-config, but it does not expose any entry to register an EnumCodec
instance, as far as my whole-day-research goes, I debugged the io.r2dbc.postgresql.PostgresqlStatement
at runtime and it was indeed using default Codecs
.
Could I please get any help, thank you in advance.