Java Community | Help. Code. Learn.JC|HCL
Java Community | Help. Code. Learn.โ€ข13mo agoโ€ข
3 replies
mahesh

Spring Boot r2dbc enum error - org.springframework.r2dbc.BadSqlGrammarException

I have been working on creating a chat_module application with Reactive programming - spring boot 3.4.1, postgres-r2dbc, and mongo reactive.

While previously I was using Strings for some columns in the postgres, the application was working fine but after i switched to enums it is giving me error.

I tried a lot of things now since last two weeks.
Configuring the EnumCodec - custom configs like - but it seems I have hit the rock bottom now.
@Configuration
public class R2dbcConfig {

    @Bean
    public R2dbcCustomConversions r2dbcCustomConversions() {
        List<Object> converters = new ArrayList<>();
        converters.add(new ChatRoomTypeReadingConverter());
        converters.add(new ChatRoomTypeWritingConverter());
        // Pass PostgresDialect.INSTANCE as the first parameter
        return R2dbcCustomConversions.of(PostgresDialect.INSTANCE, converters);
    }

    @Bean
    public CodecRegistrar enumCodecRegistrar() {
        return EnumCodec.builder()
                .withEnum("chat_room_type", ChatRoomType.class)
                .withEnum("chat_room_visibility", ChatRoomVisibility.class)
                .withEnum("chat_room_member_role", ChatRoomMemberRole.class)
                .withEnum("notification_preference", NotificationPreference.class)
                .withEnum("gender", Gender.class)
                .build();
    }
}
message.txt27.73KB
Was this page helpful?