Skip to content

Enable to persist enumeration in postgresql r2dbc #1832

@charboubmustapha

Description

@charboubmustapha

Hello Guys,
I'm using enumeration of postgresql with spring data r2dbc , i followed the documentation to register the custom converter, but the save is failing with an error of : java.lang.IllegalArgumentException: Cannot encode parameter of type com.example.r2dbc.Mode (AUTOMATIC)
Here is the converter

@WritingConverter
public class ModeConverter implements Converter<Mode, Mode> {
    @Override
    public Mode convert(@NonNull Mode pricingMode) {
        return pricingMode;
    }
}

Here is the configuration class

@Configuration
@AllArgsConstructor
public class R2dbcConfiguration extends AbstractR2dbcConfiguration {
    private final ConnectionFactory connectionFactory;

    @Override
    @NonNull
    public ConnectionFactory connectionFactory() {
        return connectionFactory;
    }


    @Override
    @NonNull
    protected List<Object> getCustomConverters() {
        return List.of(new ModeConverter());
    }
}

I created an example of project with tests : r2dbc.zip

Thank you for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions