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
In case when a custom converter is provided for a type and a null value is converted, there is no way to disambiguate whether I want it to be be left null or converted to a specific instance of the target type.
For example, if my target type is Jackson's JsonNode and the souce value is null, it's not possible to customize conversion to return just null or com.fasterxml.jackson.databind.node.NullNode.
MappingR2dbcConverter fails to convert null values to JsonNode even in the presence of the corresponding converter, see an example here.
Suppressed: org.springframework.data.mapping.MappingException: Could not read property private final com.fasterxml.jackson.databind.JsonNode com.example.r2dbcconverternull.MyRow.field1 from column field1!
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.readFrom(MappingR2dbcConverter.java:185)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.access$000(MappingR2dbcConverter.java:64)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter$RowParameterValueProvider.getParameterValue(MappingR2dbcConverter.java:706)
at app//org.springframework.data.mapping.model.SpELExpressionParameterValueProvider.getParameterValue(SpELExpressionParameterValueProvider.java:53)
at app//org.springframework.data.relational.core.conversion.BasicRelationalConverter$ConvertingParameterValueProvider.getParameterValue(BasicRelationalConverter.java:268)
at app//org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.extractInvocationArguments(ClassGeneratingEntityInstantiator.java:276)
at app//org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:248)
at app//org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:89)
at app//org.springframework.data.relational.core.conversion.BasicRelationalConverter.createInstance(BasicRelationalConverter.java:145)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.createInstance(MappingR2dbcConverter.java:326)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.read(MappingR2dbcConverter.java:124)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.read(MappingR2dbcConverter.java:119)
at app//com.example.r2dbcconverternull.R2dbcConverterNullApplicationTests.convertNullValue$lambda-0(R2dbcConverterNullApplicationTests.kt:33)
at app//io.r2dbc.h2.H2Result.lambda$map$0(H2Result.java:67)
at app//reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106)
... 181 more
Caused by: org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate com.fasterxml.jackson.databind.JsonNode using constructor protected com.fasterxml.jackson.databind.JsonNode() with arguments
at app//org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$MappingInstantiationExceptionEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:321)
at app//org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:89)
at app//org.springframework.data.relational.core.conversion.BasicRelationalConverter.createInstance(BasicRelationalConverter.java:145)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.createInstance(MappingR2dbcConverter.java:326)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.readEntityFrom(MappingR2dbcConverter.java:293)
at app//org.springframework.data.r2dbc.convert.MappingR2dbcConverter.readFrom(MappingR2dbcConverter.java:175)
... 195 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.fasterxml.jackson.databind.JsonNode]: Class is abstract
... 201 more
The text was updated successfully, but these errors were encountered:
That's by design and by intent. We generally do not convert null values. Part of the rationale is that in some cases we do not have sufficient type information (e.g. convert null to Object). What seems to be a bug is that we attempt to create an instance while the database is null. We should fix that.
We now no longer attempt to create instances of nested entities if the column value is null. Previously the null check happened after checking registered custom conversions which has lead to potential object creation for columns containing null values.
Closes#670
We now no longer attempt to create instances of nested entities if the column value is null. Previously the null check happened after checking registered custom conversions which has lead to potential object creation for columns containing null values.
Closes#670
Two related problems:
In case when a custom converter is provided for a type and a null value is converted, there is no way to disambiguate whether I want it to be be left null or converted to a specific instance of the target type.
For example, if my target type is Jackson's JsonNode and the souce value is null, it's not possible to customize conversion to return just
null
orcom.fasterxml.jackson.databind.node.NullNode
.MappingR2dbcConverter
fails to convert null values to JsonNode even in the presence of the corresponding converter, see an example here.The text was updated successfully, but these errors were encountered: