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
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:
@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
The text was updated successfully, but these errors were encountered:
@beikov AFAICS the reason is not that our specific SpaceIdViewDeserializer is no longer registered (it is), but rather that EntityViewAwareObjectMapper#EntityViewAwareObjectMapper does no add add a new objectMapper module EntityViewReferenceDeserializer (btw we should use a proper name there like SimpleModule module = new SimpleModule("EntityViewReferenceDeserializer"); and this one is picked before ours.
in the old BP implementation, EntityViewReferenceDeserializer was not registered as a deserialization module on the objectMapper used here.
I assume, the object mapper we now pass into EntityViewAwareMappingJackson2HttpMessageConverter with
Is the objectMapper that is used for deserialization here. And this object mapper know is manipulated within EntityViewAwareObjectMapper and an additional module is added, changing the behavior.
beikov
added a commit
to beikov/blaze-persistence
that referenced
this issue
Apr 19, 2024
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 EntityViewThe difference is, when deserializing, jackson (in
MethodProperty#deserializeAndSet
) uses theEntityViewReferenceDeserializer
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 aJsonNode
that only contains the value of the id (e.g. 3000) and thus cannot find an id and cannot create theEntityView
.Probably in the new version the
<EntityIdViewName>Deserializer
is not registered with theObjectMapper
.The payload we would send looks something like this:
With a DTO of:
With the idView being something like this:
In this example in the old version of Blaze, jackson would use the
NiceEntityIdViewDeserializer
while in the new versionEntityViewReferenceDeserializer
is used to deserialize theniceEntity
property inNiceEntityDTO
.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
The text was updated successfully, but these errors were encountered: