Browse Source

DATACMNS-91 - Reject null parameters in SimpleMongoRepository.

According to the specification in CrudRepository we now reject null values for ids and entities in CRUD methods.
pull/1/head
Oliver Gierke 14 years ago
parent
commit
21010fbd49
  1. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

@ -67,6 +67,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements Paging
*/ */
public T save(T entity) { public T save(T entity) {
Assert.notNull(entity, "Entity must not be null!");
mongoOperations.save(entity, entityInformation.getCollectionName()); mongoOperations.save(entity, entityInformation.getCollectionName());
return entity; return entity;
} }
@ -79,6 +81,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements Paging
*/ */
public List<T> save(Iterable<? extends T> entities) { public List<T> save(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities not be null!");
List<T> result = new ArrayList<T>(); List<T> result = new ArrayList<T>();
for (T entity : entities) { for (T entity : entities) {
@ -161,6 +165,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements Paging
*/ */
public void delete(Iterable<? extends T> entities) { public void delete(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities not be null!");
for (T entity : entities) { for (T entity : entities) {
delete(entity); delete(entity);
} }

Loading…
Cancel
Save