diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java index 045fc3555..6b386e2d5 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java @@ -66,6 +66,8 @@ public class SimpleMongoRepository implements Paging * org.springframework.data.repository.Repository#save(java.lang.Object) */ public T save(T entity) { + + Assert.notNull(entity, "Entity must not be null!"); mongoOperations.save(entity, entityInformation.getCollectionName()); return entity; @@ -79,6 +81,8 @@ public class SimpleMongoRepository implements Paging */ public List save(Iterable entities) { + Assert.notNull(entities, "The given Iterable of entities not be null!"); + List result = new ArrayList(); for (T entity : entities) { @@ -161,6 +165,8 @@ public class SimpleMongoRepository implements Paging */ public void delete(Iterable entities) { + Assert.notNull(entities, "The given Iterable of entities not be null!"); + for (T entity : entities) { delete(entity); }