diff --git a/integration/jackson/src/main/java/com/blazebit/persistence/integration/jackson/EntityViewAwareObjectMapper.java b/integration/jackson/src/main/java/com/blazebit/persistence/integration/jackson/EntityViewAwareObjectMapper.java index 4a7dc58618..ff2d4898ef 100644 --- a/integration/jackson/src/main/java/com/blazebit/persistence/integration/jackson/EntityViewAwareObjectMapper.java +++ b/integration/jackson/src/main/java/com/blazebit/persistence/integration/jackson/EntityViewAwareObjectMapper.java @@ -21,6 +21,7 @@ import com.blazebit.persistence.view.metamodel.MethodAttribute; import com.blazebit.persistence.view.metamodel.ViewMetamodel; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.BeanDescription; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.JavaType; @@ -28,6 +29,7 @@ import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.deser.AbstractDeserializer; import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier; import com.fasterxml.jackson.databind.introspect.VisibilityChecker; import com.fasterxml.jackson.databind.module.SimpleModule; @@ -51,14 +53,22 @@ public EntityViewAwareObjectMapper(final EntityViewManager entityViewManager, fi public EntityViewAwareObjectMapper(final EntityViewManager entityViewManager, final ObjectMapper objectMapper, final EntityViewIdValueAccessor entityViewIdValueAccessor) { this.entityViewManager = entityViewManager; - SimpleModule module = new SimpleModule(); + SimpleModule module = new SimpleModule("Blaze-Persistence" ); module.setDeserializerModifier(new BeanDeserializerModifier() { @Override public JsonDeserializer modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer deserializer) { - ManagedViewType view = entityViewManager.getMetamodel().managedView(beanDesc.getBeanClass()); - if (view != null) { - return new EntityViewReferenceDeserializer(entityViewManager, view, objectMapper, beanDesc.getIgnoredPropertyNames(), entityViewIdValueAccessor); + if ( deserializer instanceof AbstractDeserializer ) { + ManagedViewType view = entityViewManager.getMetamodel().managedView( beanDesc.getBeanClass() ); + if ( view != null ) { + return new EntityViewReferenceDeserializer( + entityViewManager, + view, + objectMapper, + beanDesc.getIgnoredPropertyNames(), + entityViewIdValueAccessor + ); + } } return deserializer; }