Browse Source

DATAMONGO-656 - Fixed potential NPE in MongoTemplate.

pull/34/head
Oliver Gierke 13 years ago
parent
commit
94f697da10
  1. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

@ -981,11 +981,12 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { @@ -981,11 +981,12 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
Assert.notNull(object);
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(object.getClass());
Class<?> objectType = object.getClass();
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(objectType);
MongoPersistentProperty idProp = entity == null ? null : entity.getIdProperty();
if (idProp == null) {
throw new MappingException("No id property found for object of type " + entity.getType().getName());
throw new MappingException("No id property found for object of type " + objectType);
}
ConversionService service = mongoConverter.getConversionService();

Loading…
Cancel
Save