DATAMONGO-2215 - Polishing.
Update Javadoc to reflect that array filters are used in their raw form without domain-type related type- or field mapping. Original pull request: #656.
This commit is contained in:
@@ -27,6 +27,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
@@ -402,7 +403,8 @@ public class Update implements UpdateDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter elements in an array that match the given criteria for update.
|
||||
* Filter elements in an array that match the given criteria for update. {@link CriteriaDefinition} is passed directly
|
||||
* to the driver without further type or field mapping.
|
||||
*
|
||||
* @param criteria must not be {@literal null}.
|
||||
* @return this.
|
||||
@@ -410,12 +412,13 @@ public class Update implements UpdateDefinition {
|
||||
*/
|
||||
public Update filterArray(CriteriaDefinition criteria) {
|
||||
|
||||
this.arrayFilters.add(() -> criteria.getCriteriaObject());
|
||||
this.arrayFilters.add(criteria::getCriteriaObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter elements in an array that match the given criteria for update.
|
||||
* Filter elements in an array that match the given criteria for update. {@code expression} is used directly with the
|
||||
* driver without further further type or field mapping.
|
||||
*
|
||||
* @param identifier the positional operator identifier filter criteria name.
|
||||
* @param expression the positional operator filter expression.
|
||||
|
||||
@@ -57,7 +57,8 @@ public interface UpdateDefinition {
|
||||
void inc(String key);
|
||||
|
||||
/**
|
||||
* Get the specification which elements to modify in an array field.
|
||||
* Get the specification which elements to modify in an array field. {@link ArrayFilter} are passed directly to the
|
||||
* driver without further type or field mapping.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
* @since 2.2
|
||||
@@ -80,8 +81,8 @@ public interface UpdateDefinition {
|
||||
interface ArrayFilter {
|
||||
|
||||
/**
|
||||
* Get the {@link Document} representation of the filter to apply. The returned Document is subject to mapping
|
||||
* domain type filed names.
|
||||
* Get the {@link Document} representation of the filter to apply. The returned {@link Document} is used directly
|
||||
* with the driver without further type or field mapping.
|
||||
*
|
||||
* @return never {@literal null}.
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.convert.CustomConversions;
|
||||
@@ -1058,7 +1059,7 @@ public class UpdateMapperUnitTests {
|
||||
.filterArray(Criteria.where("element").gte(100));
|
||||
|
||||
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
||||
context.getPersistentEntity(EntityWithListOfSimple.class));
|
||||
context.getPersistentEntity(EntityWithListOfIntegers.class));
|
||||
|
||||
assertThat(mappedUpdate).isEqualTo(new Document("$set", new Document("grades.$[element]", 10)));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* Repository deletes now throw `OptimisticLockingFailureException` when a versioned entity cannot be deleted.
|
||||
* Support `Range<T>` in repository between queries.
|
||||
* Kotlin extension methods accepting `KClass` are deprecated now in favor of `reified` methods.
|
||||
* Support of array filters in `Update` operations.
|
||||
|
||||
[[new-features.2-1-0]]
|
||||
== What's New in Spring Data MongoDB 2.1
|
||||
|
||||
Reference in New Issue
Block a user