Browse Source

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

pull/1/head
Mark Pollack 15 years ago
parent
commit
bee1eac360
  1. 4
      spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/convert/MappingMongoConverter.java
  2. 4
      spring-data-mongodb/src/test/java/org/springframework/data/document/mongodb/MongoTemplateTests.java

4
spring-data-mongodb/src/main/java/org/springframework/data/document/mongodb/convert/MappingMongoConverter.java

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

4
spring-data-mongodb/src/test/java/org/springframework/data/document/mongodb/MongoTemplateTests.java

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

Loading…
Cancel
Save