Class CollectionShardedMongoTemplate

  • All Implemented Interfaces:
    CollectionShardingAssistant, ShardingAssistant, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.data.mongodb.core.ExecutableAggregationOperation, org.springframework.data.mongodb.core.ExecutableFindOperation, org.springframework.data.mongodb.core.ExecutableInsertOperation, org.springframework.data.mongodb.core.ExecutableMapReduceOperation, org.springframework.data.mongodb.core.ExecutableRemoveOperation, org.springframework.data.mongodb.core.ExecutableUpdateOperation, org.springframework.data.mongodb.core.FluentMongoOperations, org.springframework.data.mongodb.core.index.IndexOperationsProvider, org.springframework.data.mongodb.core.MongoOperations

    public class CollectionShardedMongoTemplate
    extends ShardedMongoTemplate
    implements CollectionShardingAssistant
    Collection Sharded Mongo Template. To be used for collections with different names within a single MongoTemplate
    Author:
    Shashank Sharma
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableAggregationOperation

        org.springframework.data.mongodb.core.ExecutableAggregationOperation.AggregationWithAggregation<T extends Object>, org.springframework.data.mongodb.core.ExecutableAggregationOperation.AggregationWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableAggregationOperation.ExecutableAggregation<T extends Object>, org.springframework.data.mongodb.core.ExecutableAggregationOperation.TerminatingAggregation<T extends Object>
      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableFindOperation

        org.springframework.data.mongodb.core.ExecutableFindOperation.DistinctWithProjection, org.springframework.data.mongodb.core.ExecutableFindOperation.DistinctWithQuery<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.ExecutableFind<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.FindDistinct, org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithProjection<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.FindWithQuery<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingDistinct<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFind<T extends Object>, org.springframework.data.mongodb.core.ExecutableFindOperation.TerminatingFindNear<T extends Object>
      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableInsertOperation

        org.springframework.data.mongodb.core.ExecutableInsertOperation.ExecutableInsert<T extends Object>, org.springframework.data.mongodb.core.ExecutableInsertOperation.InsertWithBulkMode<T extends Object>, org.springframework.data.mongodb.core.ExecutableInsertOperation.InsertWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableInsertOperation.TerminatingBulkInsert<T extends Object>, org.springframework.data.mongodb.core.ExecutableInsertOperation.TerminatingInsert<T extends Object>
      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableMapReduceOperation

        org.springframework.data.mongodb.core.ExecutableMapReduceOperation.ExecutableMapReduce<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithMapFunction<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithOptions<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithProjection<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithQuery<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.MapReduceWithReduceFunction<T extends Object>, org.springframework.data.mongodb.core.ExecutableMapReduceOperation.TerminatingMapReduce<T extends Object>
      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableRemoveOperation

        org.springframework.data.mongodb.core.ExecutableRemoveOperation.ExecutableRemove<T extends Object>, org.springframework.data.mongodb.core.ExecutableRemoveOperation.RemoveWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableRemoveOperation.RemoveWithQuery<T extends Object>, org.springframework.data.mongodb.core.ExecutableRemoveOperation.TerminatingRemove<T extends Object>
      • Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.ExecutableUpdateOperation

        org.springframework.data.mongodb.core.ExecutableUpdateOperation.ExecutableUpdate<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.FindAndModifyWithOptions<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.FindAndReplaceWithOptions<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.FindAndReplaceWithProjection<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.TerminatingFindAndModify<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.TerminatingFindAndReplace<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.TerminatingUpdate<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.UpdateWithCollection<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.UpdateWithQuery<T extends Object>, org.springframework.data.mongodb.core.ExecutableUpdateOperation.UpdateWithUpdate<T extends Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean collectionExists​(String collectionName)  
      boolean collectionExists​(String collectionName, String collectionHint)  
      protected long doCount​(String collectionName, org.bson.Document filter, com.mongodb.client.model.CountOptions options)  
      protected com.mongodb.client.MongoCollection<org.bson.Document> doCreateCollection​(String collectionName, com.mongodb.client.model.CreateCollectionOptions createCollectionOptions)  
      protected long doEstimatedCount​(String collectionName, com.mongodb.client.model.EstimatedDocumentCountOptions options)  
      protected <T> List<T> doFind​(String collectionName, org.bson.Document query, org.bson.Document fields, Class<T> entityClass, org.springframework.data.mongodb.core.CursorPreparer preparer)  
      protected <T> List<T> doFindAndDelete​(String collectionName, org.springframework.data.mongodb.core.query.Query query, Class<T> entityClass)  
      protected <T> T doFindAndRemove​(String collectionName, org.bson.Document query, org.bson.Document fields, org.bson.Document sort, org.springframework.data.mongodb.core.query.Collation collation, Class<T> entityClass)  
      protected <T> T doFindOne​(String collectionName, org.bson.Document query, org.bson.Document fields, org.springframework.data.mongodb.core.CursorPreparer preparer, Class<T> entityClass)  
      protected <T> T doInsert​(String collectionName, T objectToSave, org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)  
      protected <T> Collection<T> doInsertBatch​(String collectionName, Collection<? extends T> batchToSave, org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)  
      protected <T> com.mongodb.client.result.DeleteResult doRemove​(String collectionName, org.springframework.data.mongodb.core.query.Query query, Class<T> entityClass, boolean multi)  
      protected <T> T doSave​(String collectionName, T objectToSave, org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)  
      protected com.mongodb.client.result.UpdateResult doUpdate​(String collectionName, org.springframework.data.mongodb.core.query.Query query, org.springframework.data.mongodb.core.query.UpdateDefinition update, Class<?> entityClass, boolean upsert, boolean multi)  
      com.mongodb.client.MongoCollection<org.bson.Document> getCollection​(String collectionName)  
      String resolveCollectionNameWithoutEntityContext​(String collectionName)
      Resolve the collection name when there is no entity context.
      • Methods inherited from class org.springframework.data.mongodb.core.MongoTemplate

        aggregate, aggregate, aggregate, aggregate, aggregate, aggregateAndReturn, aggregateStream, aggregateStream, aggregateStream, aggregateStream, aggregateStream, bulkOps, bulkOps, bulkOps, collectionExists, convertToDocument, convertToDocument, count, count, count, countCanBeEstimated, createCollection, createCollection, createCollection, createCollection, doAggregate, doCreateCollection, doExactCount, doFind, doFind, doFindAndModify, doFindAndReplace, doFindOne, doGetDatabase, doInsertAll, doStream, dropCollection, dropCollection, ensureNotCollectionLike, ensureNotIterable, estimatedCount, exactCount, execute, execute, execute, executeCommand, executeCommand, executeCommand, executeQuery, executeQuery, exists, exists, exists, find, find, findAll, findAll, findAllAndRemove, findAllAndRemove, findAllAndRemove, findAndModify, findAndModify, findAndModify, findAndModify, findAndRemove, findAndRemove, findAndReplace, findById, findById, findDistinct, findDistinct, findOne, findOne, geoNear, geoNear, geoNear, getCollectionName, getCollectionNames, getConverter, getDb, getExceptionTranslator, getMongoDatabaseFactory, getMongoDbFactory, group, group, indexOps, indexOps, indexOps, insert, insert, insert, insert, insert, insertAll, insertDocument, insertDocumentList, mapReduce, mapReduce, mapReduce, mapReduce, mapReduce, mapReduce, maybeCallAfterConvert, maybeCallAfterSave, maybeCallBeforeConvert, maybeCallBeforeSave, maybeEmitEvent, populateIdIfNecessary, prepareCollection, prepareDatabase, prepareWriteConcern, query, remove, remove, remove, remove, remove, remove, replaceWithResourceIfNecessary, save, save, saveDocument, scriptOps, setEntityCallbacks, setReadPreference, setSessionSynchronization, setWriteConcern, setWriteConcernResolver, setWriteResultChecking, stream, stream, update, updateFirst, updateFirst, updateFirst, updateMulti, updateMulti, updateMulti, upsert, upsert, upsert, useEstimatedCount, withSession, withSession
      • Methods inherited from interface org.springframework.data.mongodb.core.MongoOperations

        estimatedCount, exactCount, exactCount, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findDistinct, findDistinct, withSession
    • Constructor Detail

      • CollectionShardedMongoTemplate

        public CollectionShardedMongoTemplate​(com.mongodb.client.MongoClient mongoClient,
                                              String databaseName,
                                              CollectionShardingOptions shardingOptions)
      • CollectionShardedMongoTemplate

        public CollectionShardedMongoTemplate​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory,
                                              CollectionShardingOptions shardingOptions)
      • CollectionShardedMongoTemplate

        public CollectionShardedMongoTemplate​(org.springframework.data.mongodb.MongoDatabaseFactory mongoDbFactory,
                                              org.springframework.data.mongodb.core.convert.MongoConverter mongoConverter,
                                              CollectionShardingOptions shardingOptions)
    • Method Detail

      • doRemove

        protected <T> com.mongodb.client.result.DeleteResult doRemove​(String collectionName,
                                                                      org.springframework.data.mongodb.core.query.Query query,
                                                                      Class<T> entityClass,
                                                                      boolean multi)
        Overrides:
        doRemove in class org.springframework.data.mongodb.core.MongoTemplate
      • doInsert

        protected <T> T doInsert​(String collectionName,
                                 T objectToSave,
                                 org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)
        Overrides:
        doInsert in class org.springframework.data.mongodb.core.MongoTemplate
      • doInsertBatch

        protected <T> Collection<T> doInsertBatch​(String collectionName,
                                                  Collection<? extends T> batchToSave,
                                                  org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)
        Overrides:
        doInsertBatch in class org.springframework.data.mongodb.core.MongoTemplate
      • doSave

        protected <T> T doSave​(String collectionName,
                               T objectToSave,
                               org.springframework.data.mongodb.core.convert.MongoWriter<T> writer)
        Overrides:
        doSave in class org.springframework.data.mongodb.core.MongoTemplate
      • doFindOne

        protected <T> T doFindOne​(String collectionName,
                                  org.bson.Document query,
                                  org.bson.Document fields,
                                  org.springframework.data.mongodb.core.CursorPreparer preparer,
                                  Class<T> entityClass)
        Overrides:
        doFindOne in class org.springframework.data.mongodb.core.MongoTemplate
      • doFind

        protected <T> List<T> doFind​(String collectionName,
                                     org.bson.Document query,
                                     org.bson.Document fields,
                                     Class<T> entityClass,
                                     org.springframework.data.mongodb.core.CursorPreparer preparer)
        Overrides:
        doFind in class org.springframework.data.mongodb.core.MongoTemplate
      • doFindAndRemove

        protected <T> T doFindAndRemove​(String collectionName,
                                        org.bson.Document query,
                                        org.bson.Document fields,
                                        org.bson.Document sort,
                                        org.springframework.data.mongodb.core.query.Collation collation,
                                        Class<T> entityClass)
        Overrides:
        doFindAndRemove in class org.springframework.data.mongodb.core.MongoTemplate
      • doFindAndDelete

        protected <T> List<T> doFindAndDelete​(String collectionName,
                                              org.springframework.data.mongodb.core.query.Query query,
                                              Class<T> entityClass)
        Overrides:
        doFindAndDelete in class org.springframework.data.mongodb.core.MongoTemplate
      • doUpdate

        protected com.mongodb.client.result.UpdateResult doUpdate​(String collectionName,
                                                                  org.springframework.data.mongodb.core.query.Query query,
                                                                  org.springframework.data.mongodb.core.query.UpdateDefinition update,
                                                                  Class<?> entityClass,
                                                                  boolean upsert,
                                                                  boolean multi)
        Overrides:
        doUpdate in class org.springframework.data.mongodb.core.MongoTemplate
      • doCount

        protected long doCount​(String collectionName,
                               org.bson.Document filter,
                               com.mongodb.client.model.CountOptions options)
        Overrides:
        doCount in class org.springframework.data.mongodb.core.MongoTemplate
      • doEstimatedCount

        protected long doEstimatedCount​(String collectionName,
                                        com.mongodb.client.model.EstimatedDocumentCountOptions options)
        Overrides:
        doEstimatedCount in class org.springframework.data.mongodb.core.MongoTemplate
      • getCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getCollection​(String collectionName)
        Specified by:
        getCollection in interface org.springframework.data.mongodb.core.MongoOperations
        Overrides:
        getCollection in class org.springframework.data.mongodb.core.MongoTemplate
      • collectionExists

        public boolean collectionExists​(String collectionName)
        Specified by:
        collectionExists in interface org.springframework.data.mongodb.core.MongoOperations
        Overrides:
        collectionExists in class org.springframework.data.mongodb.core.MongoTemplate
      • collectionExists

        public boolean collectionExists​(String collectionName,
                                        String collectionHint)
      • doCreateCollection

        protected com.mongodb.client.MongoCollection<org.bson.Document> doCreateCollection​(String collectionName,
                                                                                           com.mongodb.client.model.CreateCollectionOptions createCollectionOptions)
        Overrides:
        doCreateCollection in class org.springframework.data.mongodb.core.MongoTemplate