DATAMONGO-1423 - Polishing.

Orignal pull request: #365.
This commit is contained in:
Oliver Gierke
2016-05-25 17:25:08 +02:00
parent 0e60630393
commit 4140dd573f
2 changed files with 13 additions and 3 deletions

View File

@@ -993,21 +993,30 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
}
if (obj instanceof DBObject) {
DBObject newValueDbo = new BasicDBObject();
for (String vk : ((DBObject) obj).keySet()) {
Object o = ((DBObject) obj).get(vk);
newValueDbo.put(vk, convertToMongoType(o, typeHint));
}
return newValueDbo;
}
if (obj instanceof Map) {
Map<Object, Object> converted = new LinkedHashMap<Object, Object>();
for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) obj).entrySet()) {
converted.put(convertToMongoType(entry.getKey()), convertToMongoType(entry.getValue(),
typeHint != null && typeHint.getMapValueType() != null ? typeHint.getMapValueType() : typeHint));
for (Entry<Object, Object> entry : ((Map<Object, Object>) obj).entrySet()) {
TypeInformation<? extends Object> valueTypeHint = typeHint != null && typeHint.getMapValueType() != null
? typeHint.getMapValueType() : typeHint;
converted.put(convertToMongoType(entry.getKey()), convertToMongoType(entry.getValue(), valueTypeHint));
}
return new BasicDBObject(converted);
}

View File

@@ -916,6 +916,7 @@ public class UpdateMapperUnitTests {
* @see DATAMONGO-1423
*/
@Test
@SuppressWarnings("unchecked")
public void mappingShouldConsiderCustomConvertersForEnumMapKeys() {
CustomConversions conversions = new CustomConversions(