Skip to content

Commit a120ce2

Browse files
committed
DATAMONGO-776 - Improvement in TypeBasedAggregationOperationContext.
TypeBasedAggregationOperationContext's getReference(…) doesn't use a PropertyPath anymore to avoid running the camel case property resolution.
1 parent a5d40a0 commit a120ce2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContext.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@ public FieldReference getReference(Field field) {
8888
*/
8989
@Override
9090
public FieldReference getReference(String name) {
91-
PropertyPath path = PropertyPath.from(name, type);
9291

93-
PersistentPropertyPath<MongoPersistentProperty> propertyPath = mappingContext.getPersistentPropertyPath(path);
92+
PersistentPropertyPath<MongoPersistentProperty> propertyPath = mappingContext.getPersistentPropertyPath(name, type);
9493

95-
return getReferenceFor(field(path.getLeafProperty().getSegment(),
94+
return getReferenceFor(field(propertyPath.getLeafProperty().getName(),
9695
propertyPath.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE)));
9796
}
9897

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.junit.runner.RunWith;
2424
import org.mockito.Mock;
2525
import org.mockito.runners.MockitoJUnitRunner;
26-
import org.springframework.data.mapping.PropertyReferenceException;
26+
import org.springframework.data.mapping.model.MappingException;
2727
import org.springframework.data.mongodb.MongoDbFactory;
2828
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
2929
import org.springframework.data.mongodb.core.convert.QueryMapper;
@@ -56,7 +56,7 @@ public void findsSimpleReference() {
5656
assertThat(getContext(Foo.class).getReference("bar"), is(notNullValue()));
5757
}
5858

59-
@Test(expected = PropertyReferenceException.class)
59+
@Test(expected = MappingException.class)
6060
public void rejectsInvalidFieldReference() {
6161
getContext(Foo.class).getReference("foo");
6262
}

0 commit comments

Comments
 (0)