I can see that JPA/Hibernate/Spring Data invokes this empty constructor and Description value object is initialized with {{null}, i.e. Description(null).
When I step forward and RepositoryInvoker finds all results using Pageable, description value object fields in Product entity are set to null instead of Description(null).
Why is that?
Is is possible to have it as I describe above?
The side effect of this is that my custom DescriptionSerializer
is never invoked because of how Jackson works internally, UnwrappingBeanPropertyWriter doesn't unwrap null value objects.
Patrik Mihalcin opened DATAREST-1175 and commented
Hi..
Let's say I have value object:
and entity:
and custom Description serializer:
In a database, I have null in
DESCRIPTION
column ofPRODUCT
tableWhen I put breakpoint here:
spring-data-rest/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java
Line 202 in 9b0f0c7
and inside:
I can see that JPA/Hibernate/Spring Data invokes this empty constructor and
Description
value object is initialized with {{null}, i.e. Description(null).When I step forward and
RepositoryInvoker
finds all results usingPageable
, description value object fields inProduct
entity are set to null instead ofDescription(null)
.Why is that?
Is is possible to have it as I describe above?
The side effect of this is that my custom
DescriptionSerializer
is never invoked because of how Jackson works internally,
UnwrappingBeanPropertyWriter
doesn't unwrap null value objects.See here for the reference: https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnwrappingBeanPropertyWriter.java#L89
So to sum it up:
null value objects are not unwrapped properly using Jackson and I don't see expected JSON content:
what leads to inconsistent REST API where description is omitted completely.
Frontend clients written in React are sensitive to this behaviour.
No further details from DATAREST-1175
The text was updated successfully, but these errors were encountered: