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?
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.