You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use com.fasterxml.jackson.databind.JsonNode for json values in my entities, and there is JsonNode to io.r2dbc.postgresql.codec.Json Reading/Writing converters registered in my DataAccessStrategy.
But when I want to use JsonNode as the value for update (data is instance of JsonNode), I`m get an exception:
return r2dbcTemplate.update(Entity.class)
.matching(query(where("id").is(id).and("key").is(key)))
.apply(Update.update("data",data)
.set("updated", OffsetDateTime.now()));
java.lang.IllegalArgumentException: Cannot encode parameter of type java.util.ArrayList ([[], []])
at io.r2dbc.postgresql.codec.DefaultCodecs.encodeParameterValue(DefaultCodecs.java:276)
As I can find out, this happens because JsonNode implements Iterable and there is following code in QueryMapper#convertValue:
if (value instanceof Iterable) {
List<Object> mapped = new ArrayList<>();
for (Object o : (Iterable<?>) value) {
mapped.add(convertValue(o, typeInformation.getActualType() != null ? typeInformation.getRequiredActualType()
: ClassTypeInformation.OBJECT));
}
return mapped;
}
if (value.getClass().isArray()
&& (ClassTypeInformation.OBJECT.equals(typeInformation) || typeInformation.isCollectionLike())) {
return value;
}
return this.converter.writeValue(value, typeInformation);
The text was updated successfully, but these errors were encountered:
mp911de
changed the title
Custom converter is not used for conversion in org.springframework.data.r2dbc.query.QueryMapper if value implements Iterable
Custom converter is not used for conversion in QueryMapper if value implements IterableMar 15, 2023
org.springframework.data:spring-data-r2dbc -> 1.5.5
I use com.fasterxml.jackson.databind.JsonNode for json values in my entities, and there is JsonNode to io.r2dbc.postgresql.codec.Json Reading/Writing converters registered in my DataAccessStrategy.
But when I want to use JsonNode as the value for update (data is instance of JsonNode), I`m get an exception:
As I can find out, this happens because JsonNode implements Iterable and there is following code in QueryMapper#convertValue:
The text was updated successfully, but these errors were encountered: