Search in sources :

Example 21 with Collation

use of org.springframework.data.mongodb.core.query.Collation in project spring-data-mongodb by spring-projects.

the class ReactiveMongoTemplate method doUpdate.

protected Mono<UpdateResult> doUpdate(final String collectionName, @Nullable Query query, @Nullable Update update, @Nullable Class<?> entityClass, final boolean upsert, final boolean multi) {
    MongoPersistentEntity<?> entity = entityClass == null ? null : getPersistentEntity(entityClass);
    Flux<UpdateResult> result = execute(collectionName, collection -> {
        increaseVersionForUpdateIfNecessary(entity, update);
        Document queryObj = query == null ? new Document() : queryMapper.getMappedObject(query.getQueryObject(), entity);
        Document updateObj = update == null ? new Document() : updateMapper.getMappedObject(update.getUpdateObject(), entity);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(String.format("Calling update using query: %s and update: %s in collection: %s", serializeToJsonSafely(queryObj), serializeToJsonSafely(updateObj), collectionName));
        }
        MongoAction mongoAction = new MongoAction(writeConcern, MongoActionOperation.UPDATE, collectionName, entityClass, updateObj, queryObj);
        WriteConcern writeConcernToUse = prepareWriteConcern(mongoAction);
        MongoCollection<Document> collectionToUse = prepareCollection(collection, writeConcernToUse);
        UpdateOptions updateOptions = new UpdateOptions().upsert(upsert);
        query.getCollation().map(Collation::toMongoCollation).ifPresent(updateOptions::collation);
        if (!UpdateMapper.isUpdateObject(updateObj)) {
            return collectionToUse.replaceOne(queryObj, updateObj, updateOptions);
        }
        if (multi) {
            return collectionToUse.updateMany(queryObj, updateObj, updateOptions);
        }
        return collectionToUse.updateOne(queryObj, updateObj, updateOptions);
    }).doOnNext(updateResult -> {
        if (entity != null && entity.hasVersionProperty() && !multi) {
            if (updateResult.wasAcknowledged() && updateResult.getMatchedCount() == 0) {
                Document queryObj = query == null ? new Document() : queryMapper.getMappedObject(query.getQueryObject(), entity);
                Document updateObj = update == null ? new Document() : updateMapper.getMappedObject(update.getUpdateObject(), entity);
                if (dbObjectContainsVersionProperty(queryObj, entity))
                    throw new OptimisticLockingFailureException("Optimistic lock exception on saving entity: " + updateObj.toString() + " to collection " + collectionName);
            }
        }
    });
    return result.next();
}
Also used : Document(org.bson.Document) PropertyReferenceException(org.springframework.data.mapping.PropertyReferenceException) DeleteOptions(com.mongodb.client.model.DeleteOptions) MongoCollection(com.mongodb.reactivestreams.client.MongoCollection) PersistentPropertyAccessor(org.springframework.data.mapping.PersistentPropertyAccessor) ClientSession(com.mongodb.session.ClientSession) FullDocument(com.mongodb.client.model.changestream.FullDocument) Optionals(org.springframework.data.util.Optionals) UpdateResult(com.mongodb.client.result.UpdateResult) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) UpdateOptions(com.mongodb.client.model.UpdateOptions) AggregationOperationContext(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext) ClassUtils(org.springframework.util.ClassUtils) NonNull(lombok.NonNull) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) FindPublisher(com.mongodb.reactivestreams.client.FindPublisher) PropertyPath(org.springframework.data.mapping.PropertyPath) Id(org.springframework.data.annotation.Id) SpelAwareProxyProjectionFactory(org.springframework.data.projection.SpelAwareProxyProjectionFactory) ApplicationContextAware(org.springframework.context.ApplicationContextAware) AfterDeleteEvent(org.springframework.data.mongodb.core.mapping.event.AfterDeleteEvent) java.util(java.util) Validator(org.springframework.data.mongodb.core.validation.Validator) MappingContext(org.springframework.data.mapping.context.MappingContext) FindOneAndUpdateOptions(com.mongodb.client.model.FindOneAndUpdateOptions) CountOptions(com.mongodb.client.model.CountOptions) MongoClient(com.mongodb.reactivestreams.client.MongoClient) Bson(org.bson.conversions.Bson) Filters(com.mongodb.client.model.Filters) ProjectionInformation(org.springframework.data.projection.ProjectionInformation) MappingException(org.springframework.data.mapping.MappingException) CreateCollectionOptions(com.mongodb.client.model.CreateCollectionOptions) MongoDatabase(com.mongodb.reactivestreams.client.MongoDatabase) ConvertingPropertyAccessor(org.springframework.data.mapping.model.ConvertingPropertyAccessor) Nullable(org.springframework.lang.Nullable) MongoSimpleTypes(org.springframework.data.mongodb.core.mapping.MongoSimpleTypes) Success(com.mongodb.reactivestreams.client.Success) ConversionService(org.springframework.core.convert.ConversionService) BeforeConvertEvent(org.springframework.data.mongodb.core.mapping.event.BeforeConvertEvent) PrefixingDelegatingAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.PrefixingDelegatingAggregationOperationContext) AfterConvertEvent(org.springframework.data.mongodb.core.mapping.event.AfterConvertEvent) BeforeSaveEvent(org.springframework.data.mongodb.core.mapping.event.BeforeSaveEvent) ReactiveIndexOperations(org.springframework.data.mongodb.core.index.ReactiveIndexOperations) Publisher(org.reactivestreams.Publisher) ObjectUtils(org.springframework.util.ObjectUtils) TypedAggregation(org.springframework.data.mongodb.core.aggregation.TypedAggregation) Mono(reactor.core.publisher.Mono) BeansException(org.springframework.beans.BeansException) MongoMappingEventPublisher(org.springframework.data.mongodb.core.index.MongoMappingEventPublisher) Criteria(org.springframework.data.mongodb.core.query.Criteria) Flux(reactor.core.publisher.Flux) ObjectId(org.bson.types.ObjectId) MongoMappingEvent(org.springframework.data.mongodb.core.mapping.event.MongoMappingEvent) org.springframework.data.mongodb.core.convert(org.springframework.data.mongodb.core.convert) JSONParseException(com.mongodb.util.JSONParseException) RequiredArgsConstructor(lombok.RequiredArgsConstructor) LoggerFactory(org.slf4j.LoggerFactory) Collation(org.springframework.data.mongodb.core.query.Collation) MongoClientVersion(org.springframework.data.mongodb.util.MongoClientVersion) BeforeDeleteEvent(org.springframework.data.mongodb.core.mapping.event.BeforeDeleteEvent) BsonValue(org.bson.BsonValue) PersistenceExceptionTranslator(org.springframework.dao.support.PersistenceExceptionTranslator) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) com.mongodb(com.mongodb) Pair(org.springframework.data.util.Pair) Update(org.springframework.data.mongodb.core.query.Update) MongoPersistentEntityIndexCreator(org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator) SerializationUtils(org.springframework.data.mongodb.core.query.SerializationUtils) ReturnDocument(com.mongodb.client.model.ReturnDocument) ApplicationListener(org.springframework.context.ApplicationListener) Collectors(java.util.stream.Collectors) Entry(java.util.Map.Entry) Codec(org.bson.codecs.Codec) ReactiveMongoDatabaseFactory(org.springframework.data.mongodb.ReactiveMongoDatabaseFactory) TypeBasedAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext) Metric(org.springframework.data.geo.Metric) DataAccessException(org.springframework.dao.DataAccessException) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) Tuple2(reactor.util.function.Tuple2) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) DistinctPublisher(com.mongodb.reactivestreams.client.DistinctPublisher) Function(java.util.function.Function) Distance(org.springframework.data.geo.Distance) EntityReader(org.springframework.data.convert.EntityReader) AfterLoadEvent(org.springframework.data.mongodb.core.mapping.event.AfterLoadEvent) FindOneAndDeleteOptions(com.mongodb.client.model.FindOneAndDeleteOptions) ChangeStreamPublisher(com.mongodb.reactivestreams.client.ChangeStreamPublisher) MongoPersistentEntity(org.springframework.data.mongodb.core.mapping.MongoPersistentEntity) ValidationOptions(com.mongodb.client.model.ValidationOptions) Nonnull(javax.annotation.Nonnull) ApplicationEventPublisherAware(org.springframework.context.ApplicationEventPublisherAware) Logger(org.slf4j.Logger) AggregationOptions(org.springframework.data.mongodb.core.aggregation.AggregationOptions) IndexOperationsAdapter(org.springframework.data.mongodb.core.index.IndexOperationsAdapter) ApplicationContext(org.springframework.context.ApplicationContext) Query(org.springframework.data.mongodb.core.query.Query) Consumer(java.util.function.Consumer) AfterSaveEvent(org.springframework.data.mongodb.core.mapping.event.AfterSaveEvent) AggregatePublisher(com.mongodb.reactivestreams.client.AggregatePublisher) DeleteResult(com.mongodb.client.result.DeleteResult) GeoResult(org.springframework.data.geo.GeoResult) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) MongoCollection(com.mongodb.reactivestreams.client.MongoCollection) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) Document(org.bson.Document) FullDocument(com.mongodb.client.model.changestream.FullDocument) ReturnDocument(com.mongodb.client.model.ReturnDocument) Collation(org.springframework.data.mongodb.core.query.Collation) UpdateResult(com.mongodb.client.result.UpdateResult) UpdateOptions(com.mongodb.client.model.UpdateOptions) FindOneAndUpdateOptions(com.mongodb.client.model.FindOneAndUpdateOptions)

Example 22 with Collation

use of org.springframework.data.mongodb.core.query.Collation in project cas by apereo.

the class MongoDbWebAuthnCredentialRepository method getRegistrationsByUsername.

@Override
public Collection<CredentialRegistration> getRegistrationsByUsername(final String username) {
    val query = new Query().addCriteria(Criteria.where(MongoDbWebAuthnCredentialRegistration.FIELD_USERNAME).is(username)).collation(Collation.of(Locale.ENGLISH).strength(Collation.ComparisonLevel.primary()));
    val records = mongoTemplate.find(query, MongoDbWebAuthnCredentialRegistration.class, getProperties().getAuthn().getMfa().getWebAuthn().getMongo().getCollection());
    return records.stream().map(record -> getCipherExecutor().decode(record.getRecords())).map(Unchecked.function(record -> WebAuthnUtils.getObjectMapper().readValue(record, new TypeReference<Set<CredentialRegistration>>() {
    }))).flatMap(Collection::stream).collect(Collectors.toList());
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) Unchecked(org.jooq.lambda.Unchecked) SneakyThrows(lombok.SneakyThrows) CipherExecutor(org.apereo.cas.util.crypto.CipherExecutor) Collection(java.util.Collection) lombok.val(lombok.val) CredentialRegistration(com.yubico.data.CredentialRegistration) Set(java.util.Set) BaseWebAuthnCredentialRepository(org.apereo.cas.webauthn.storage.BaseWebAuthnCredentialRepository) Collation(org.springframework.data.mongodb.core.query.Collation) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Locale(java.util.Locale) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) Update(org.springframework.data.mongodb.core.query.Update) Clock(java.time.Clock) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Set(java.util.Set) Query(org.springframework.data.mongodb.core.query.Query)

Example 23 with Collation

use of org.springframework.data.mongodb.core.query.Collation in project spring-data-mongodb by spring-projects.

the class AggregationOptions method fromDocument.

/**
 * Creates new {@link AggregationOptions} given {@link Document} containing aggregation options.
 *
 * @param document must not be {@literal null}.
 * @return the {@link AggregationOptions}.
 * @since 2.0
 */
public static AggregationOptions fromDocument(Document document) {
    Assert.notNull(document, "Document must not be null!");
    boolean allowDiskUse = document.getBoolean(ALLOW_DISK_USE, false);
    boolean explain = document.getBoolean(EXPLAIN, false);
    Document cursor = document.get(CURSOR, Document.class);
    Collation collation = document.containsKey(COLLATION) ? Collation.from(document.get(COLLATION, Document.class)) : null;
    String comment = document.getString(COMMENT);
    Document hint = document.get(HINT, Document.class);
    AggregationOptions options = new AggregationOptions(allowDiskUse, explain, cursor, collation, comment, hint);
    if (document.containsKey(MAX_TIME)) {
        options.maxTime = Duration.ofMillis(document.getLong(MAX_TIME));
    }
    return options;
}
Also used : Document(org.bson.Document) Collation(org.springframework.data.mongodb.core.query.Collation)

Example 24 with Collation

use of org.springframework.data.mongodb.core.query.Collation in project spring-data-mongodb by spring-projects.

the class DefaultReactiveIndexOperationsTests method shouldCreateIndexWithCollationCorrectly.

// DATAMONGO-1518
@Test
public void shouldCreateIndexWithCollationCorrectly() {
    IndexDefinition id = new Index().named("with-collation").on("xyz", Direction.ASC).collation(Collation.of("de_AT").caseFirst(CaseFirst.off()));
    indexOps.ensureIndex(id).as(StepVerifier::create).expectNextCount(1).verifyComplete();
    Document expected = // 
    new Document("locale", "de_AT").append("caseLevel", // 
    false).append("caseFirst", // 
    "off").append("strength", // 
    3).append("numericOrdering", // 
    false).append("alternate", // 
    "non-ignorable").append("maxVariable", // 
    "punct").append("normalization", // 
    false).append("backwards", false);
    // 
    indexOps.getIndexInfo().filter(this.indexByName("with-collation")).as(StepVerifier::create).consumeNextWith(indexInfo -> {
        assertThat(indexInfo.getCollation()).isPresent();
        // version is set by MongoDB server - we remove it to avoid errors when upgrading server version.
        Document result = indexInfo.getCollation().get();
        result.remove("version");
        assertThat(result).isEqualTo(expected);
    }).verifyComplete();
}
Also used : Document(org.bson.Document) BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper) Predicate(java.util.function.Predicate) ReactiveMongoTestTemplate(org.springframework.data.mongodb.test.util.ReactiveMongoTestTemplate) Collation(org.springframework.data.mongodb.core.query.Collation) Template(org.springframework.data.mongodb.test.util.Template) MongoCollection(com.mongodb.reactivestreams.client.MongoCollection) Index(org.springframework.data.mongodb.core.index.Index) Criteria(org.springframework.data.mongodb.core.query.Criteria) Field(org.springframework.data.mongodb.core.mapping.Field) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) PartialIndexFilter(org.springframework.data.mongodb.core.index.PartialIndexFilter) Assertions(org.assertj.core.api.Assertions) Direction(org.springframework.data.domain.Sort.Direction) CaseFirst(org.springframework.data.mongodb.core.query.Collation.CaseFirst) MongoTemplateExtension(org.springframework.data.mongodb.test.util.MongoTemplateExtension) IndexInfo(org.springframework.data.mongodb.core.index.IndexInfo) IndexDefinition(org.springframework.data.mongodb.core.index.IndexDefinition) IndexDefinition(org.springframework.data.mongodb.core.index.IndexDefinition) Index(org.springframework.data.mongodb.core.index.Index) StepVerifier(reactor.test.StepVerifier) Document(org.bson.Document) Test(org.junit.jupiter.api.Test)

Example 25 with Collation

use of org.springframework.data.mongodb.core.query.Collation in project spring-data-mongodb by spring-projects.

the class MongoTemplate method aggregateStream.

@SuppressWarnings("ConstantConditions")
protected <O> CloseableIterator<O> aggregateStream(Aggregation aggregation, String collectionName, Class<O> outputType, @Nullable AggregationOperationContext context) {
    Assert.hasText(collectionName, "Collection name must not be null or empty!");
    Assert.notNull(aggregation, "Aggregation pipeline must not be null!");
    Assert.notNull(outputType, "Output type must not be null!");
    Assert.isTrue(!aggregation.getOptions().isExplain(), "Can't use explain option with streaming!");
    AggregationDefinition aggregationDefinition = queryOperations.createAggregation(aggregation, context);
    AggregationOptions options = aggregation.getOptions();
    List<Document> pipeline = aggregationDefinition.getAggregationPipeline();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(String.format("Streaming aggregation: %s in collection %s", serializeToJsonSafely(pipeline), collectionName));
    }
    ReadDocumentCallback<O> readCallback = new ReadDocumentCallback<>(mongoConverter, outputType, collectionName);
    return execute(collectionName, (CollectionCallback<CloseableIterator<O>>) collection -> {
        AggregateIterable<Document> cursor = collection.aggregate(pipeline, Document.class).allowDiskUse(options.isAllowDiskUse());
        if (options.getCursorBatchSize() != null) {
            cursor = cursor.batchSize(options.getCursorBatchSize());
        }
        options.getComment().ifPresent(cursor::comment);
        options.getHint().ifPresent(cursor::hint);
        Class<?> domainType = aggregation instanceof TypedAggregation ? ((TypedAggregation) aggregation).getInputType() : null;
        Optionals.firstNonEmpty(options::getCollation, () -> operations.forType(domainType).getCollation()).map(Collation::toMongoCollation).ifPresent(cursor::collation);
        return new CloseableIterableCursorAdapter<>(cursor, exceptionTranslator, readCallback);
    });
}
Also used : Document(org.bson.Document) EntityCallbacks(org.springframework.data.mapping.callback.EntityCallbacks) BasicQuery(org.springframework.data.mongodb.core.query.BasicQuery) NumberUtils(org.springframework.util.NumberUtils) BsonUtils(org.springframework.data.mongodb.util.BsonUtils) MongoDatabase(com.mongodb.client.MongoDatabase) BigDecimal(java.math.BigDecimal) QueryContext(org.springframework.data.mongodb.core.QueryOperations.QueryContext) BulkOperationContext(org.springframework.data.mongodb.core.DefaultBulkOperations.BulkOperationContext) Optionals(org.springframework.data.util.Optionals) UpdateResult(com.mongodb.client.result.UpdateResult) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) MapReduceResults(org.springframework.data.mongodb.core.mapreduce.MapReduceResults) CursorOption(org.springframework.data.mongodb.core.query.Meta.CursorOption) MongoJsonSchemaMapper(org.springframework.data.mongodb.core.convert.MongoJsonSchemaMapper) Resource(org.springframework.core.io.Resource) AggregationOperationContext(org.springframework.data.mongodb.core.aggregation.AggregationOperationContext) ClassUtils(org.springframework.util.ClassUtils) NearQuery(org.springframework.data.mongodb.core.query.NearQuery) AggregateIterable(com.mongodb.client.AggregateIterable) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) CollectionUtils(org.springframework.util.CollectionUtils) LogFactory(org.apache.commons.logging.LogFactory) DistinctQueryContext(org.springframework.data.mongodb.core.QueryOperations.DistinctQueryContext) ApplicationContextAware(org.springframework.context.ApplicationContextAware) MongoDatabaseUtils(org.springframework.data.mongodb.MongoDatabaseUtils) java.util(java.util) Validator(org.springframework.data.mongodb.core.validation.Validator) IndexOperationsProvider(org.springframework.data.mongodb.core.index.IndexOperationsProvider) MongoCollection(com.mongodb.client.MongoCollection) MongoCustomConversions(org.springframework.data.mongodb.core.convert.MongoCustomConversions) GroupByResults(org.springframework.data.mongodb.core.mapreduce.GroupByResults) MappingContext(org.springframework.data.mapping.context.MappingContext) UpdateDefinition(org.springframework.data.mongodb.core.query.UpdateDefinition) Bson(org.bson.conversions.Bson) DbRefResolver(org.springframework.data.mongodb.core.convert.DbRefResolver) MappingException(org.springframework.data.mapping.MappingException) Nullable(org.springframework.lang.Nullable) JsonSchemaMapper(org.springframework.data.mongodb.core.convert.JsonSchemaMapper) com.mongodb.client.model(com.mongodb.client.model) CountContext(org.springframework.data.mongodb.core.QueryOperations.CountContext) org.springframework.data.mongodb.core.mapping.event(org.springframework.data.mongodb.core.mapping.event) QueryMapper(org.springframework.data.mongodb.core.convert.QueryMapper) ObjectUtils(org.springframework.util.ObjectUtils) DeleteContext(org.springframework.data.mongodb.core.QueryOperations.DeleteContext) TypedAggregation(org.springframework.data.mongodb.core.aggregation.TypedAggregation) IOException(java.io.IOException) BeansException(org.springframework.beans.BeansException) MongoMappingEventPublisher(org.springframework.data.mongodb.core.index.MongoMappingEventPublisher) Criteria(org.springframework.data.mongodb.core.query.Criteria) ResourceUtils(org.springframework.util.ResourceUtils) DistinctIterable(com.mongodb.client.DistinctIterable) DefaultDbRefResolver(org.springframework.data.mongodb.core.convert.DefaultDbRefResolver) MongoIterable(com.mongodb.client.MongoIterable) CloseableIterator(org.springframework.data.util.CloseableIterator) Collation(org.springframework.data.mongodb.core.query.Collation) EntityProjection(org.springframework.data.projection.EntityProjection) PersistenceExceptionTranslator(org.springframework.dao.support.PersistenceExceptionTranslator) OptimisticLockingFailureException(org.springframework.dao.OptimisticLockingFailureException) MapReduceOptions(org.springframework.data.mongodb.core.mapreduce.MapReduceOptions) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MapReduceIterable(com.mongodb.client.MapReduceIterable) AdaptibleEntity(org.springframework.data.mongodb.core.EntityOperations.AdaptibleEntity) MongoWriter(org.springframework.data.mongodb.core.convert.MongoWriter) RoundingMode(java.math.RoundingMode) Meta(org.springframework.data.mongodb.core.query.Meta) ResourceLoader(org.springframework.core.io.ResourceLoader) MongoPersistentEntityIndexCreator(org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator) SerializationUtils(org.springframework.data.mongodb.core.query.SerializationUtils) MongoException(com.mongodb.MongoException) ApplicationListener(org.springframework.context.ApplicationListener) AggregationResults(org.springframework.data.mongodb.core.aggregation.AggregationResults) Collectors(java.util.stream.Collectors) FindIterable(com.mongodb.client.FindIterable) UpdateMapper(org.springframework.data.mongodb.core.convert.UpdateMapper) TypeBasedAggregationOperationContext(org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext) UpdateContext(org.springframework.data.mongodb.core.QueryOperations.UpdateContext) Metric(org.springframework.data.geo.Metric) ReadPreference(com.mongodb.ReadPreference) DataAccessException(org.springframework.dao.DataAccessException) MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) MongoClient(com.mongodb.client.MongoClient) BulkMode(org.springframework.data.mongodb.core.BulkOperations.BulkMode) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) MongoDatabaseFactory(org.springframework.data.mongodb.MongoDatabaseFactory) MongoConverter(org.springframework.data.mongodb.core.convert.MongoConverter) Distance(org.springframework.data.geo.Distance) IndexOperations(org.springframework.data.mongodb.core.index.IndexOperations) EntityReader(org.springframework.data.convert.EntityReader) ArrayFilter(org.springframework.data.mongodb.core.query.UpdateDefinition.ArrayFilter) MongoCursor(com.mongodb.client.MongoCursor) Granularity(org.springframework.data.mongodb.core.timeseries.Granularity) MongoPersistentEntity(org.springframework.data.mongodb.core.mapping.MongoPersistentEntity) AggregationDefinition(org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition) GroupBy(org.springframework.data.mongodb.core.mapreduce.GroupBy) ApplicationEventPublisherAware(org.springframework.context.ApplicationEventPublisherAware) AggregationOptions(org.springframework.data.mongodb.core.aggregation.AggregationOptions) ApplicationContext(org.springframework.context.ApplicationContext) Query(org.springframework.data.mongodb.core.query.Query) TimeUnit(java.util.concurrent.TimeUnit) MappingMongoConverter(org.springframework.data.mongodb.core.convert.MappingMongoConverter) ClientSessionOptions(com.mongodb.ClientSessionOptions) GeoResults(org.springframework.data.geo.GeoResults) DeleteResult(com.mongodb.client.result.DeleteResult) Log(org.apache.commons.logging.Log) ClientSession(com.mongodb.client.ClientSession) GeoResult(org.springframework.data.geo.GeoResult) SessionSynchronization(org.springframework.data.mongodb.SessionSynchronization) WriteConcern(com.mongodb.WriteConcern) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) AggregationOptions(org.springframework.data.mongodb.core.aggregation.AggregationOptions) CloseableIterator(org.springframework.data.util.CloseableIterator) AggregationDefinition(org.springframework.data.mongodb.core.QueryOperations.AggregationDefinition) Document(org.bson.Document) Collation(org.springframework.data.mongodb.core.query.Collation) TypedAggregation(org.springframework.data.mongodb.core.aggregation.TypedAggregation) AggregateIterable(com.mongodb.client.AggregateIterable)

Aggregations

Collation (org.springframework.data.mongodb.core.query.Collation)33 Query (org.springframework.data.mongodb.core.query.Query)24 Test (org.junit.jupiter.api.Test)19 Document (org.bson.Document)15 Collectors (java.util.stream.Collectors)7 DataAccessException (org.springframework.dao.DataAccessException)7 BasicQuery (org.springframework.data.mongodb.core.query.BasicQuery)7 MongoException (com.mongodb.MongoException)6 WriteConcern (com.mongodb.WriteConcern)6 DeleteResult (com.mongodb.client.result.DeleteResult)6 UpdateResult (com.mongodb.client.result.UpdateResult)6 AggregationOptions (org.springframework.data.mongodb.core.aggregation.AggregationOptions)6 TypedAggregation (org.springframework.data.mongodb.core.aggregation.TypedAggregation)6 Criteria (org.springframework.data.mongodb.core.query.Criteria)5 MongoPersistentEntity (org.springframework.data.mongodb.core.mapping.MongoPersistentEntity)4 FullDocument (com.mongodb.client.model.changestream.FullDocument)3 java.util (java.util)3 Collection (java.util.Collection)3 Bson (org.bson.conversions.Bson)3 BeansException (org.springframework.beans.BeansException)3