committed by
Mark Paluch
parent
a9d2050806
commit
6e4d463053
@@ -187,7 +187,9 @@ public interface ExecutableMapReduceOperation {
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
|
* @deprecated since 4.0 in favor of {@link org.springframework.data.mongodb.core.aggregation}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
interface MapReduceWithOptions<T> {
|
interface MapReduceWithOptions<T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import org.springframework.data.mongodb.core.schema.JsonSchemaProperty;
|
|||||||
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
|
import org.springframework.data.mongodb.core.schema.MongoJsonSchema;
|
||||||
import org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder;
|
import org.springframework.data.mongodb.core.schema.MongoJsonSchema.MongoJsonSchemaBuilder;
|
||||||
import org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject;
|
import org.springframework.data.mongodb.core.schema.TypedJsonSchemaObject;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -267,7 +267,7 @@ class MappingMongoJsonSchemaCreator implements MongoJsonSchemaCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSpecificType(MongoPersistentProperty property) {
|
private boolean isSpecificType(MongoPersistentProperty property) {
|
||||||
return !ClassTypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
|
return !TypeInformation.OBJECT.equals(property.getTypeInformation().getActualType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonSchemaProperty applyEncryptionDataIfNecessary(MongoPersistentProperty property,
|
private JsonSchemaProperty applyEncryptionDataIfNecessary(MongoPersistentProperty property,
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.springframework.data.convert.TypeInformationMapper;
|
|||||||
import org.springframework.data.mapping.Alias;
|
import org.springframework.data.mapping.Alias;
|
||||||
import org.springframework.data.mapping.PersistentEntity;
|
import org.springframework.data.mapping.PersistentEntity;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
@@ -52,9 +51,9 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper<Bson> implements M
|
|||||||
|
|
||||||
public static final String DEFAULT_TYPE_KEY = "_class";
|
public static final String DEFAULT_TYPE_KEY = "_class";
|
||||||
@SuppressWarnings("rawtypes") //
|
@SuppressWarnings("rawtypes") //
|
||||||
private static final TypeInformation<List> LIST_TYPE_INFO = ClassTypeInformation.from(List.class);
|
private static final TypeInformation<List> LIST_TYPE_INFO = TypeInformation.of(List.class);
|
||||||
@SuppressWarnings("rawtypes") //
|
@SuppressWarnings("rawtypes") //
|
||||||
private static final TypeInformation<Map> MAP_TYPE_INFO = ClassTypeInformation.from(Map.class);
|
private static final TypeInformation<Map> MAP_TYPE_INFO = TypeInformation.MAP;
|
||||||
|
|
||||||
private final TypeAliasAccessor<Bson> accessor;
|
private final TypeAliasAccessor<Bson> accessor;
|
||||||
private final @Nullable String typeKey;
|
private final @Nullable String typeKey;
|
||||||
@@ -139,7 +138,7 @@ public class DefaultMongoTypeMapper extends DefaultTypeMapper<Bson> implements M
|
|||||||
|
|
||||||
for (Class<?> restrictedType : restrictedTypes) {
|
for (Class<?> restrictedType : restrictedTypes) {
|
||||||
|
|
||||||
Alias typeAlias = getAliasFor(ClassTypeInformation.from(restrictedType));
|
Alias typeAlias = getAliasFor(TypeInformation.of(restrictedType));
|
||||||
|
|
||||||
if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
|
if (!ObjectUtils.nullSafeEquals(Alias.NONE, typeAlias) && typeAlias.isPresent()) {
|
||||||
restrictedMappedTypes.add(typeAlias.getValue());
|
restrictedMappedTypes.add(typeAlias.getValue());
|
||||||
|
|||||||
@@ -50,16 +50,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
|
|||||||
import org.springframework.data.annotation.Reference;
|
import org.springframework.data.annotation.Reference;
|
||||||
import org.springframework.data.convert.CustomConversions;
|
import org.springframework.data.convert.CustomConversions;
|
||||||
import org.springframework.data.convert.TypeMapper;
|
import org.springframework.data.convert.TypeMapper;
|
||||||
import org.springframework.data.mapping.AccessOptions;
|
import org.springframework.data.mapping.*;
|
||||||
import org.springframework.data.mapping.Association;
|
|
||||||
import org.springframework.data.mapping.MappingException;
|
|
||||||
import org.springframework.data.mapping.Parameter;
|
|
||||||
import org.springframework.data.mapping.PersistentEntity;
|
|
||||||
import org.springframework.data.mapping.PersistentProperty;
|
|
||||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
|
||||||
import org.springframework.data.mapping.PersistentPropertyPath;
|
|
||||||
import org.springframework.data.mapping.PersistentPropertyPathAccessor;
|
|
||||||
import org.springframework.data.mapping.PreferredConstructor;
|
|
||||||
import org.springframework.data.mapping.callback.EntityCallbacks;
|
import org.springframework.data.mapping.callback.EntityCallbacks;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||||
@@ -123,7 +114,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s; Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions; Parent object was: %4$s";
|
private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s; Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions; Parent object was: %4$s";
|
||||||
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter";
|
private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter";
|
||||||
|
|
||||||
public static final ClassTypeInformation<Bson> BSON = ClassTypeInformation.from(Bson.class);
|
public static final TypeInformation<Bson> BSON = TypeInformation.of(Bson.class);
|
||||||
|
|
||||||
protected static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
|
protected static final Log LOGGER = LogFactory.getLog(MappingMongoConverter.class);
|
||||||
|
|
||||||
@@ -353,9 +344,9 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PreferredConstructor<?, MongoPersistentProperty> persistenceConstructor = mappedEntity.getPersistenceConstructor();
|
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = mappedEntity.getInstanceCreatorMetadata();
|
||||||
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
|
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
|
||||||
&& persistenceConstructor.hasParameters()
|
&& instanceCreatorMetadata.hasParameters()
|
||||||
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
|
? getParameterProvider(context, mappedEntity, documentAccessor, evaluator)
|
||||||
: NoOpParameterValueProvider.INSTANCE;
|
: NoOpParameterValueProvider.INSTANCE;
|
||||||
|
|
||||||
@@ -405,7 +396,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <S extends Object> S read(Class<S> clazz, Bson bson) {
|
public <S extends Object> S read(Class<S> clazz, Bson bson) {
|
||||||
return read(ClassTypeInformation.from(clazz), bson);
|
return read(TypeInformation.of(clazz), bson);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <S extends Object> S read(TypeInformation<S> type, Bson bson) {
|
protected <S extends Object> S read(TypeInformation<S> type, Bson bson) {
|
||||||
@@ -498,10 +489,10 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext);
|
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(bson, spELContext);
|
||||||
DocumentAccessor documentAccessor = new DocumentAccessor(bson);
|
DocumentAccessor documentAccessor = new DocumentAccessor(bson);
|
||||||
|
|
||||||
PreferredConstructor<S, MongoPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor();
|
InstanceCreatorMetadata<MongoPersistentProperty> instanceCreatorMetadata = entity.getInstanceCreatorMetadata();
|
||||||
|
|
||||||
ParameterValueProvider<MongoPersistentProperty> provider = persistenceConstructor != null
|
ParameterValueProvider<MongoPersistentProperty> provider = instanceCreatorMetadata != null
|
||||||
&& persistenceConstructor.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
|
&& instanceCreatorMetadata.hasParameters() ? getParameterProvider(context, entity, documentAccessor, evaluator)
|
||||||
: NoOpParameterValueProvider.INSTANCE;
|
: NoOpParameterValueProvider.INSTANCE;
|
||||||
|
|
||||||
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
|
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
|
||||||
@@ -552,7 +543,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
|
|
||||||
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
|
MongoPersistentProperty idProperty = entity.getRequiredIdProperty();
|
||||||
|
|
||||||
if (idProperty.isImmutable() && entity.isConstructorArgument(idProperty)) {
|
if (idProperty.isImmutable() && entity.isCreatorArgument(idProperty)) {
|
||||||
return rawId;
|
return rawId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +578,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
ConversionContext propertyContext = context.forProperty(prop);
|
ConversionContext propertyContext = context.forProperty(prop);
|
||||||
MongoDbPropertyValueProvider valueProviderToUse = valueProvider.withContext(propertyContext);
|
MongoDbPropertyValueProvider valueProviderToUse = valueProvider.withContext(propertyContext);
|
||||||
|
|
||||||
if (prop.isAssociation() && !entity.isConstructorArgument(prop)) {
|
if (prop.isAssociation() && !entity.isCreatorArgument(prop)) {
|
||||||
|
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = getDbRefResolverCallback(propertyContext, documentAccessor, evaluator);
|
callback = getDbRefResolverCallback(propertyContext, documentAccessor, evaluator);
|
||||||
@@ -761,7 +752,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
|
|
||||||
Class<?> entityType = ClassUtils.getUserClass(obj.getClass());
|
Class<?> entityType = ClassUtils.getUserClass(obj.getClass());
|
||||||
TypeInformation<? extends Object> type = ClassTypeInformation.from(entityType);
|
TypeInformation<? extends Object> type = TypeInformation.of(entityType);
|
||||||
|
|
||||||
Object target = obj instanceof LazyLoadingProxy ? ((LazyLoadingProxy) obj).getTarget() : obj;
|
Object target = obj instanceof LazyLoadingProxy ? ((LazyLoadingProxy) obj).getTarget() : obj;
|
||||||
|
|
||||||
@@ -805,12 +796,12 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Map.class.isAssignableFrom(entityType)) {
|
if (Map.class.isAssignableFrom(entityType)) {
|
||||||
writeMapInternal((Map<Object, Object>) obj, bson, ClassTypeInformation.MAP);
|
writeMapInternal((Map<Object, Object>) obj, bson, TypeInformation.MAP);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Collection.class.isAssignableFrom(entityType)) {
|
if (Collection.class.isAssignableFrom(entityType)) {
|
||||||
writeCollectionInternal((Collection<?>) obj, ClassTypeInformation.LIST, (Collection<?>) bson);
|
writeCollectionInternal((Collection<?>) obj, TypeInformation.LIST, (Collection<?>) bson);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -896,7 +887,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInformation<?> valueType = ClassTypeInformation.from(obj.getClass());
|
TypeInformation<?> valueType = TypeInformation.of(obj.getClass());
|
||||||
TypeInformation<?> type = prop.getTypeInformation();
|
TypeInformation<?> type = prop.getTypeInformation();
|
||||||
|
|
||||||
if (conversions.hasValueConverter(prop)) {
|
if (conversions.hasValueConverter(prop)) {
|
||||||
@@ -977,7 +968,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
Document document = existingValue instanceof Document ? (Document) existingValue : new Document();
|
Document document = existingValue instanceof Document ? (Document) existingValue : new Document();
|
||||||
|
|
||||||
writeInternal(obj, document, entity);
|
writeInternal(obj, document, entity);
|
||||||
addCustomTypeKeyIfNecessary(ClassTypeInformation.from(prop.getRawType()), obj, document);
|
addCustomTypeKeyIfNecessary(TypeInformation.of(prop.getRawType()), obj, document);
|
||||||
accessor.put(prop, document);
|
accessor.put(prop, document);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -998,7 +989,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
.getPointer();
|
.getPointer();
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
return writeCollectionInternal(targetCollection, ClassTypeInformation.from(DocumentPointer.class),
|
return writeCollectionInternal(targetCollection, TypeInformation.of(DocumentPointer.class),
|
||||||
new ArrayList<>());
|
new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1127,7 +1118,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
} else {
|
} else {
|
||||||
Document document = new Document();
|
Document document = new Document();
|
||||||
TypeInformation<?> valueTypeInfo = propertyType.isMap() ? propertyType.getMapValueType()
|
TypeInformation<?> valueTypeInfo = propertyType.isMap() ? propertyType.getMapValueType()
|
||||||
: ClassTypeInformation.OBJECT;
|
: TypeInformation.OBJECT;
|
||||||
writeInternal(val, document, valueTypeInfo);
|
writeInternal(val, document, valueTypeInfo);
|
||||||
BsonUtils.addToMap(bson, simpleKey, document);
|
BsonUtils.addToMap(bson, simpleKey, document);
|
||||||
}
|
}
|
||||||
@@ -1379,7 +1370,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
|
|
||||||
TypeInformation<?> componentType = targetType.getComponentType() != null //
|
TypeInformation<?> componentType = targetType.getComponentType() != null //
|
||||||
? targetType.getComponentType() //
|
? targetType.getComponentType() //
|
||||||
: ClassTypeInformation.OBJECT;
|
: TypeInformation.OBJECT;
|
||||||
Class<?> rawComponentType = componentType.getType();
|
Class<?> rawComponentType = componentType.getType();
|
||||||
|
|
||||||
Collection<Object> items = targetType.getType().isArray() //
|
Collection<Object> items = targetType.getType().isArray() //
|
||||||
@@ -1421,7 +1412,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
Class<?> mapType = getTypeMapper().readType(bson, targetType).getType();
|
Class<?> mapType = getTypeMapper().readType(bson, targetType).getType();
|
||||||
|
|
||||||
TypeInformation<?> keyType = targetType.getComponentType();
|
TypeInformation<?> keyType = targetType.getComponentType();
|
||||||
TypeInformation<?> valueType = targetType.getMapValueType() == null ? ClassTypeInformation.OBJECT
|
TypeInformation<?> valueType = targetType.getMapValueType() == null ? TypeInformation.OBJECT
|
||||||
: targetType.getRequiredMapValueType();
|
: targetType.getRequiredMapValueType();
|
||||||
|
|
||||||
Class<?> rawKeyType = keyType != null ? keyType.getType() : Object.class;
|
Class<?> rawKeyType = keyType != null ? keyType.getType() : Object.class;
|
||||||
@@ -1827,7 +1818,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Predicate<MongoPersistentProperty> isConstructorArgument(PersistentEntity<?, ?> entity) {
|
static Predicate<MongoPersistentProperty> isConstructorArgument(PersistentEntity<?, ?> entity) {
|
||||||
return entity::isConstructorArgument;
|
return entity::isCreatorArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2046,7 +2037,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.springframework.data.util.TypeInformation<?> getComponentType() {
|
public org.springframework.data.util.TypeInformation<?> getComponentType() {
|
||||||
return ClassTypeInformation.from(persistentProperty.getFieldType());
|
return TypeInformation.of(persistentProperty.getFieldType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2056,7 +2047,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.springframework.data.util.TypeInformation<?> getMapValueType() {
|
public org.springframework.data.util.TypeInformation<?> getMapValueType() {
|
||||||
return ClassTypeInformation.from(persistentProperty.getFieldType());
|
return TypeInformation.of(persistentProperty.getFieldType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty.Pro
|
|||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.data.mongodb.util.BsonUtils;
|
import org.springframework.data.mongodb.util.BsonUtils;
|
||||||
import org.springframework.data.mongodb.util.DotPath;
|
import org.springframework.data.mongodb.util.DotPath;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@@ -78,7 +77,7 @@ public class QueryMapper {
|
|||||||
|
|
||||||
private static final List<String> DEFAULT_ID_NAMES = Arrays.asList("id", "_id");
|
private static final List<String> DEFAULT_ID_NAMES = Arrays.asList("id", "_id");
|
||||||
private static final Document META_TEXT_SCORE = new Document("$meta", "textScore");
|
private static final Document META_TEXT_SCORE = new Document("$meta", "textScore");
|
||||||
static final ClassTypeInformation<?> NESTED_DOCUMENT = ClassTypeInformation.from(NestedDocument.class);
|
static final TypeInformation<?> NESTED_DOCUMENT = TypeInformation.of(NestedDocument.class);
|
||||||
|
|
||||||
private enum MetaMapping {
|
private enum MetaMapping {
|
||||||
FORCE, WHEN_PRESENT, IGNORE
|
FORCE, WHEN_PRESENT, IGNORE
|
||||||
@@ -1040,7 +1039,7 @@ public class QueryMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TypeInformation<?> getTypeHint() {
|
public TypeInformation<?> getTypeHint() {
|
||||||
return ClassTypeInformation.OBJECT;
|
return TypeInformation.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1352,7 +1351,7 @@ public class QueryMapper {
|
|||||||
|
|
||||||
if (property.getActualType().isInterface()
|
if (property.getActualType().isInterface()
|
||||||
|| java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) {
|
|| java.lang.reflect.Modifier.isAbstract(property.getActualType().getModifiers())) {
|
||||||
return ClassTypeInformation.OBJECT;
|
return TypeInformation.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NESTED_DOCUMENT;
|
return NESTED_DOCUMENT;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
|||||||
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.data.mongodb.core.query.Query;
|
||||||
import org.springframework.data.mongodb.core.query.Update.Modifier;
|
import org.springframework.data.mongodb.core.query.Update.Modifier;
|
||||||
import org.springframework.data.mongodb.core.query.Update.Modifiers;
|
import org.springframework.data.mongodb.core.query.Update.Modifiers;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
@@ -134,7 +133,7 @@ public class UpdateMapper extends QueryMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return converter.convertToMongoType(source,
|
return converter.convertToMongoType(source,
|
||||||
entity == null ? ClassTypeInformation.OBJECT : getTypeHintForEntity(source, entity));
|
entity == null ? TypeInformation.OBJECT : getTypeHintForEntity(source, entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,7 +208,7 @@ public class UpdateMapper extends QueryMapper {
|
|||||||
: getMappedSort(sortObject, field.getPropertyEntity());
|
: getMappedSort(sortObject, field.getPropertyEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInformation<?> typeHint = field == null ? ClassTypeInformation.OBJECT : field.getTypeHint();
|
TypeInformation<?> typeHint = field == null ? TypeInformation.OBJECT : field.getTypeHint();
|
||||||
|
|
||||||
return converter.convertToMongoType(value, typeHint);
|
return converter.convertToMongoType(value, typeHint);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class IndexInfo {
|
|||||||
indexFields.add(IndexField.wildcard(key));
|
indexFields.add(IndexField.wildcard(key));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Double keyValue = new Double(value.toString());
|
Double keyValue = Double.valueOf(value.toString());
|
||||||
|
|
||||||
if (ONE.equals(keyValue)) {
|
if (ONE.equals(keyValue)) {
|
||||||
indexFields.add(IndexField.create(key, ASC));
|
indexFields.add(IndexField.create(key, ASC));
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import org.springframework.data.mapping.context.MappingContext;
|
|||||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ public interface IndexResolver {
|
|||||||
* @see 2.2
|
* @see 2.2
|
||||||
*/
|
*/
|
||||||
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
|
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
|
||||||
return resolveIndexFor(ClassTypeInformation.from(entityType));
|
return resolveIndexFor(TypeInformation.of(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.springframework.data.mongodb.repository.Near;
|
|||||||
import org.springframework.data.mongodb.repository.query.MongoParameters.MongoParameter;
|
import org.springframework.data.mongodb.repository.query.MongoParameters.MongoParameter;
|
||||||
import org.springframework.data.repository.query.Parameter;
|
import org.springframework.data.repository.query.Parameter;
|
||||||
import org.springframework.data.repository.query.Parameters;
|
import org.springframework.data.repository.query.Parameters;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ public class MongoParameters extends Parameters<MongoParameters, MongoParameter>
|
|||||||
|
|
||||||
this.fullTextIndex = parameterTypes.indexOf(TextCriteria.class);
|
this.fullTextIndex = parameterTypes.indexOf(TextCriteria.class);
|
||||||
|
|
||||||
ClassTypeInformation<?> declaringClassInfo = ClassTypeInformation.from(method.getDeclaringClass());
|
TypeInformation<?> declaringClassInfo = TypeInformation.of(method.getDeclaringClass());
|
||||||
List<TypeInformation<?>> parameterTypeInfo = declaringClassInfo.getParameterTypes(method);
|
List<TypeInformation<?>> parameterTypeInfo = declaringClassInfo.getParameterTypes(method);
|
||||||
|
|
||||||
this.rangeIndex = getTypeIndex(parameterTypeInfo, Range.class, Distance.class);
|
this.rangeIndex = getTypeIndex(parameterTypeInfo, Range.class, Distance.class);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ import org.springframework.data.projection.ProjectionFactory;
|
|||||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||||
import org.springframework.data.repository.query.QueryMethod;
|
import org.springframework.data.repository.query.QueryMethod;
|
||||||
import org.springframework.data.repository.util.ReactiveWrappers;
|
import org.springframework.data.repository.util.ReactiveWrappers;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.Lazy;
|
import org.springframework.data.util.Lazy;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
@@ -195,7 +194,7 @@ public class MongoQueryMethod extends QueryMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Iterable.class.isAssignableFrom(returnType)) {
|
if (Iterable.class.isAssignableFrom(returnType)) {
|
||||||
TypeInformation<?> from = ClassTypeInformation.fromReturnTypeOf(method);
|
TypeInformation<?> from = TypeInformation.fromReturnTypeOf(method);
|
||||||
return GeoResult.class.equals(from.getRequiredComponentType().getType());
|
return GeoResult.class.equals(from.getRequiredComponentType().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,7 +216,7 @@ public class MongoQueryMethod extends QueryMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeInformation<?> getReturnType() {
|
TypeInformation<?> getReturnType() {
|
||||||
return ClassTypeInformation.fromReturnTypeOf(method);
|
return TypeInformation.fromReturnTypeOf(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import org.springframework.data.projection.ProjectionFactory;
|
|||||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||||
import org.springframework.data.repository.util.ReactiveWrapperConverters;
|
import org.springframework.data.repository.util.ReactiveWrapperConverters;
|
||||||
import org.springframework.data.repository.util.ReactiveWrappers;
|
import org.springframework.data.repository.util.ReactiveWrappers;
|
||||||
import org.springframework.data.util.ClassTypeInformation;
|
|
||||||
import org.springframework.data.util.Lazy;
|
import org.springframework.data.util.Lazy;
|
||||||
import org.springframework.data.util.TypeInformation;
|
import org.springframework.data.util.TypeInformation;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
@@ -47,8 +46,8 @@ import org.springframework.util.ClassUtils;
|
|||||||
*/
|
*/
|
||||||
public class ReactiveMongoQueryMethod extends MongoQueryMethod {
|
public class ReactiveMongoQueryMethod extends MongoQueryMethod {
|
||||||
|
|
||||||
private static final ClassTypeInformation<Page> PAGE_TYPE = ClassTypeInformation.from(Page.class);
|
private static final TypeInformation<Page> PAGE_TYPE = TypeInformation.of(Page.class);
|
||||||
private static final ClassTypeInformation<Slice> SLICE_TYPE = ClassTypeInformation.from(Slice.class);
|
private static final TypeInformation<Slice> SLICE_TYPE = TypeInformation.of(Slice.class);
|
||||||
|
|
||||||
private final Method method;
|
private final Method method;
|
||||||
private final Lazy<Boolean> isCollectionQuery;
|
private final Lazy<Boolean> isCollectionQuery;
|
||||||
@@ -89,7 +88,7 @@ public class ReactiveMongoQueryMethod extends MongoQueryMethod {
|
|||||||
private boolean isGeoNearQuery(Method method) {
|
private boolean isGeoNearQuery(Method method) {
|
||||||
|
|
||||||
if (ReactiveWrappers.supports(method.getReturnType())) {
|
if (ReactiveWrappers.supports(method.getReturnType())) {
|
||||||
TypeInformation<?> from = ClassTypeInformation.fromReturnTypeOf(method);
|
TypeInformation<?> from = TypeInformation.fromReturnTypeOf(method);
|
||||||
return GeoResult.class.equals(from.getRequiredComponentType().getType());
|
return GeoResult.class.equals(from.getRequiredComponentType().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +131,7 @@ public class ReactiveMongoQueryMethod extends MongoQueryMethod {
|
|||||||
|
|
||||||
if (hasParameterOfType(method, Pageable.class)) {
|
if (hasParameterOfType(method, Pageable.class)) {
|
||||||
|
|
||||||
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
|
TypeInformation<?> returnType = TypeInformation.fromReturnTypeOf(method);
|
||||||
|
|
||||||
boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
|
boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
|
||||||
boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())
|
boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())
|
||||||
|
|||||||
Reference in New Issue
Block a user