DATADOC-86 - Bug in deserialisation of Entitys with Embedded Collections

This commit is contained in:
Mark Pollack
2011-04-09 17:24:32 -04:00
parent f6d4cc615a
commit bee1eac360
2 changed files with 7 additions and 5 deletions

View File

@@ -299,8 +299,8 @@ public class MappingMongoConverter implements MongoConverter, ApplicationContext
}
if (null == entity) {
// Must not have explictly added this entity yet
entity = mappingContext.addPersistentEntity(obj.getClass());
// Must not have explictly added this entity yet
entity = mappingContext.addPersistentEntity(obj.getClass());
if (null == entity) {
// We can't map this entity for some reason
throw new MappingException("Unable to map entity " + obj);
@@ -327,7 +327,7 @@ public class MappingMongoConverter implements MongoConverter, ApplicationContext
}
}
}
// Write the properties
entity.doWithProperties(new PropertyHandler() {
public void doWithPersistentProperty(PersistentProperty prop) {
@@ -419,6 +419,8 @@ public class MappingMongoConverter implements MongoConverter, ApplicationContext
DBRef dbRef = createDBRef(propObjItem, dbref);
dbList.add(dbRef);
} else if (type.isArray() && MappingBeanHelper.isSimpleType(type.getComponentType())) {
dbList.add(propObjItem);
} else if (MappingBeanHelper.isSimpleType(propObjItem.getClass())) {
dbList.add(propObjItem);
} else {
BasicDBObject propDbObj = new BasicDBObject();

View File

@@ -337,13 +337,13 @@ public class MongoTemplateTests {
testAddingToList(this.template);
}
//@Test
@Test
public void testAddingToListWithMappingConverter() throws Exception {
testAddingToList(this.mappingTemplate);
}
private void testAddingToList(MongoTemplate template) {
PersonWithAList p = new PersonWithAList();
PersonWithAList p = new PersonWithAList();
p.setFirstName("Sven");
p.setAge(22);
template.insert(p);