Source:
private <R> R readMapValue(@Nullable Map<String, Object> source, ElasticsearchPersistentProperty property, TypeInformation<R> targetType) { TypeInformation<?> information = typeMapper.readType(source); if (property.isEntity() && !property.isMap() || information != null) { ElasticsearchPersistentEntity<?> targetEntity = information != null ? mappingContext.getRequiredPersistentEntity(information) : mappingContext.getRequiredPersistentEntity(property); return readEntity(targetEntity, source); } Map<String, Object> target = new LinkedHashMap<>(); for (Entry<String, Object> entry : source.entrySet()) { if(null == entry.getValue()) { target.put(entry.getKey(),null); continue ; } if (isSimpleType(entry.getValue())) { target.put(entry.getKey(), readSimpleValue(entry.getValue(), targetType.isMap() ? targetType.getComponentType() : targetType)); } else { ElasticsearchPersistentEntity<?> targetEntity = computeGenericValueTypeForRead(property, entry.getValue()); if (targetEntity.getTypeInformation().isMap()) { Map<String, Object> valueMap = (Map<String, Object>) entry.getValue(); if (typeMapper.containsTypeInformation(valueMap)) { target.put(entry.getKey(), readEntity(targetEntity, valueMap)); } else { target.put(entry.getKey(), readValue(valueMap, property, targetEntity.getTypeInformation())); } } else if (targetEntity.getTypeInformation().isCollectionLike()) { target.put(entry.getKey(), readValue(entry.getValue(), property, targetEntity.getTypeInformation().getActualType())); } else { target.put(entry.getKey(), readEntity(targetEntity, (Map<String, Object>) entry.getValue())); } } } return (R) target; }

Target:
private <R> R readMapValue(@Nullable Map<String, Object> source, ElasticsearchPersistentProperty property, TypeInformation<R> targetType) { TypeInformation<?> information = typeMapper.readType(source); if (property.isEntity() && !property.isMap() || information != null) { ElasticsearchPersistentEntity<?> targetEntity = information != null ? mappingContext.getRequiredPersistentEntity(information) : mappingContext.getRequiredPersistentEntity(property); return readEntity(targetEntity, source); } Map<String, Object> target = new LinkedHashMap<>(); for (Entry<String, Object> entry : source.entrySet()) { if(entry.getValue() == null) { target.put(entry.getKey(),null); } else if (isSimpleType(entry.getValue())) { target.put(entry.getKey(), readSimpleValue(entry.getValue(), targetType.isMap() ? targetType.getComponentType() : targetType)); } else { ElasticsearchPersistentEntity<?> targetEntity = computeGenericValueTypeForRead(property, entry.getValue()); if (targetEntity.getTypeInformation().isMap()) { Map<String, Object> valueMap = (Map<String, Object>) entry.getValue(); if (typeMapper.containsTypeInformation(valueMap)) { target.put(entry.getKey(), readEntity(targetEntity, valueMap)); } else { target.put(entry.getKey(), readValue(valueMap, property, targetEntity.getTypeInformation())); } } else if (targetEntity.getTypeInformation().isCollectionLike()) { target.put(entry.getKey(), readValue(entry.getValue(), property, targetEntity.getTypeInformation().getActualType())); } else { target.put(entry.getKey(), readEntity(targetEntity, (Map<String, Object>) entry.getValue())); } } } return (R) target; }