Skip to content

Commit 6937bb5

Browse files
committed
Polishing.
Move off more deprecated API. See #4164 Original pull request: #4165.
1 parent 6e4d463 commit 6937bb5

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DocumentPointerFactory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.springframework.data.annotation.Reference;
3030
import org.springframework.data.mapping.PersistentPropertyAccessor;
3131
import org.springframework.data.mapping.PersistentPropertyPath;
32+
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
3233
import org.springframework.data.mapping.PropertyPath;
3334
import org.springframework.data.mapping.context.MappingContext;
3435
import org.springframework.data.mapping.model.BeanWrapperPropertyAccessorFactory;
@@ -239,9 +240,11 @@ Object updatePlaceholders(org.bson.Document source, org.bson.Document target,
239240
continue;
240241
}
241242

243+
PersistentPropertyPathAccessor<?> propertyPathAccessor = persistentEntity
244+
.getPropertyPathAccessor(propertyAccessor.getBean());
242245
PersistentPropertyPath<?> path = mappingContext
243246
.getPersistentPropertyPath(PropertyPath.from(fieldName, persistentEntity.getTypeInformation()));
244-
Object targetValue = propertyAccessor.getProperty(path);
247+
Object targetValue = propertyPathAccessor.getProperty(path);
245248
target.put(attribute, targetValue);
246249
continue;
247250
}

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.bson.conversions.Bson;
4040
import org.bson.json.JsonReader;
4141
import org.bson.types.ObjectId;
42+
4243
import org.springframework.beans.BeansException;
4344
import org.springframework.beans.factory.BeanClassLoaderAware;
4445
import org.springframework.context.ApplicationContext;
@@ -50,7 +51,16 @@
5051
import org.springframework.data.annotation.Reference;
5152
import org.springframework.data.convert.CustomConversions;
5253
import org.springframework.data.convert.TypeMapper;
53-
import org.springframework.data.mapping.*;
54+
import org.springframework.data.mapping.AccessOptions;
55+
import org.springframework.data.mapping.Association;
56+
import org.springframework.data.mapping.InstanceCreatorMetadata;
57+
import org.springframework.data.mapping.MappingException;
58+
import org.springframework.data.mapping.Parameter;
59+
import org.springframework.data.mapping.PersistentEntity;
60+
import org.springframework.data.mapping.PersistentProperty;
61+
import org.springframework.data.mapping.PersistentPropertyAccessor;
62+
import org.springframework.data.mapping.PersistentPropertyPath;
63+
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
5464
import org.springframework.data.mapping.callback.EntityCallbacks;
5565
import org.springframework.data.mapping.context.MappingContext;
5666
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
@@ -344,7 +354,8 @@ String getFieldName(MongoPersistentProperty prop) {
344354
}
345355
};
346356

347-
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity.getInstanceCreatorMetadata();
357+
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity
358+
.getInstanceCreatorMetadata();
348359
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
349360
&& instanceCreatorMetadata.hasParameters()
350361
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
@@ -989,8 +1000,7 @@ protected List<Object> createCollection(Collection<?> collection, MongoPersisten
9891000
.getPointer();
9901001
}).collect(Collectors.toList());
9911002

992-
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
993-
new ArrayList<>());
1003+
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class), new ArrayList<>());
9941004
}
9951005

9961006
if (property.hasExplicitWriteTarget()) {
@@ -2091,7 +2101,7 @@ public List<org.springframework.data.util.TypeInformation<?>> getTypeArguments()
20912101
}
20922102

20932103
@Override
2094-
public org.springframework.data.util.TypeInformation<? extends S> specialize(ClassTypeInformation type) {
2104+
public org.springframework.data.util.TypeInformation<? extends S> specialize(TypeInformation<?> type) {
20952105
return delegate.specialize(type);
20962106
}
20972107

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.Arrays;
1919
import java.util.List;
2020

21-
import org.springframework.data.annotation.PersistenceConstructor;
21+
import org.springframework.data.annotation.PersistenceCreator;
2222
import org.springframework.data.geo.Circle;
2323
import org.springframework.data.geo.Distance;
2424
import org.springframework.data.geo.Point;
@@ -44,7 +44,7 @@ public class Sphere implements Shape {
4444
* @param center must not be {@literal null}.
4545
* @param radius must not be {@literal null}.
4646
*/
47-
@PersistenceConstructor
47+
@PersistenceCreator
4848
public Sphere(Point center, Distance radius) {
4949

5050
Assert.notNull(center, "Center point must not be null");

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/UnwrappedMongoPersistentEntity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public String getName() {
9999

100100
@Override
101101
@Nullable
102+
@Deprecated
102103
public PreferredConstructor<T, MongoPersistentProperty> getPersistenceConstructor() {
103104
return delegate.getPersistenceConstructor();
104105
}
@@ -110,7 +111,7 @@ public InstanceCreatorMetadata<MongoPersistentProperty> getInstanceCreatorMetada
110111

111112
@Override
112113
public boolean isCreatorArgument(PersistentProperty<?> property) {
113-
return delegate.isConstructorArgument(property);
114+
return delegate.isCreatorArgument(property);
114115
}
115116

116117
@Override

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/ReactiveGridFsTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public <T> Mono<T> store(GridFsObject<T, Publisher<DataBuffer>> upload) {
127127
}
128128

129129
String filename = upload.getFilename();
130-
Flux<ByteBuffer> source = Flux.from(upload.getContent()).map(DataBuffer::asByteBuffer);
130+
Flux<ByteBuffer> source = Flux.from(upload.getContent()).map(DataBuffer::toByteBuffer);
131131
T fileId = upload.getFileId();
132132

133133
if (fileId == null) {

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractReactiveMongoQuery.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,23 +369,6 @@ protected Mono<ParameterBindingDocumentCodec> getParameterBindingCodec() {
369369
return getCodecRegistry().map(ParameterBindingDocumentCodec::new);
370370
}
371371

372-
/**
373-
* Obtain a {@link Mono publisher} emitting the {@link SpELExpressionEvaluator} suitable to evaluate expressions
374-
* backed by the given dependencies.
375-
*
376-
* @param dependencies must not be {@literal null}.
377-
* @param accessor must not be {@literal null}.
378-
* @return a {@link Mono} emitting the {@link SpELExpressionEvaluator} when ready.
379-
* @since 2.4
380-
* @deprecated in favor of {@link #getSpelEvaluatorFor(ExpressionDependencies, MongoParameterAccessor)}
381-
*/
382-
@Deprecated
383-
protected Mono<SpELExpressionEvaluator> getSpelEvaluatorFor(ExpressionDependencies dependencies,
384-
ConvertingParameterAccessor accessor) {
385-
386-
return getSpelEvaluatorFor(dependencies, (MongoParameterAccessor) accessor);
387-
}
388-
389372
/**
390373
* Obtain a {@link Mono publisher} emitting the {@link SpELExpressionEvaluator} suitable to evaluate expressions
391374
* backed by the given dependencies.

0 commit comments

Comments
 (0)