Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding array(list) type conversions in Spring Data R2DBC

I'm using Postgres as my datasource and I've created a custom Spring converter for a property that holds a list of my custom objects:

@Slf4j
@WritingConverter
@AllArgsConstructor
public class CustomObjectListToStringConverter implements Converter<List<CustomObject>, String> {

    @Override
    public String convert(@Nonnull List<CustomObject> source) {
        try {
            return objectMapper.writeValueAsString(source);
        } catch (JsonProcessingException e) {
            log.error("Error occurred while serializing list of CustomObject to JSON.", e);
        }
        return "[]";
    }

}

Conversion goes smoothly but IllegalArgumentException is raised in getArrayType method of PostgresArrayColumns class because my custom type is not a simple type.

Is there a way to circumvent this guard for some property?

like image 450
NikolaB Avatar asked Oct 20 '25 05:10

NikolaB


1 Answers

Currently, there is no override possible because DatabaseClient considers collection-typed values as values for Postgres' array fields. Please file a ticket at https://github.com/spring-projects/spring-data-r2dbc/ to fix the issue.

like image 169
mp911de Avatar answered Oct 22 '25 22:10

mp911de