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.
This commit is contained in:
Oliver Gierke
2011-12-02 13:34:44 +01:00
parent 4325d6c9fa
commit 21010fbd49

View File

@@ -66,6 +66,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> 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<T, ID extends Serializable> implements Paging
*/
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>();
for (T entity : entities) {
@@ -161,6 +165,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements Paging
*/
public void delete(Iterable<? extends T> entities) {
Assert.notNull(entities, "The given Iterable of entities not be null!");
for (T entity : entities) {
delete(entity);
}