Deserializing EntityViews with jackson in Springboot yields null instead of an EntityView #1878
Description
Description
When deserializing an EntityView in a DTO as payload in a @RequestBody
the new Blaze version deserializes null while the old version can transform the id that is set, e.g. 3000 to the respective EntityView
The difference is, when deserializing, jackson (in MethodProperty#deserializeAndSet
) uses the EntityViewReferenceDeserializer
in the newer case (probably as a fallback implementation) while when using the old Blaze version <EntityIdViewName>Deserializer
is used.
The EntityViewReferenceDeserializer
(new version) starts looking for an { idAttribute: <Id>}
(com.blazebit.persistence.integration.jackson.EntityViewReferenceDeserializer#retrieveId)
in a JsonNode
that only contains the value of the id (e.g. 3000) and thus cannot find an id and cannot create the EntityView
.
Probably in the new version the <EntityIdViewName>Deserializer
is not registered with the ObjectMapper
.
The payload we would send looks something like this:
{ niceEntity: 3000, ... }
With a DTO of:
@Data
....
NiceEntityDTO {
private NiceEntityIdView niceEntity;
...
}
With the idView being something like this:
@EntityView(NiceEntity::class)
interface LongIdView {
@get:IdMapping
val id: Long?
}
In this example in the old version of Blaze, jackson would use the NiceEntityIdViewDeserializer
while in the new version EntityViewReferenceDeserializer
is used to deserialize the niceEntity
property in NiceEntityDTO
.
Expected behavior
After deserialization the DTO class should contain a NiceEntityIdView with an id of 3000.
Actual behavior
After deserialization the DTO class should contains null for the niceEntity field.
Environment
Current Version: latest master build,
Before Version: based on 191e130
JPA-Provider: Hibernate 6.4.4.Final