Class DefaultReactiveMongoRepositoryOperations
java.lang.Object
io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperations
io.micronaut.data.mongodb.operations.DefaultReactiveMongoRepositoryOperations
- All Implemented Interfaces:
- io.micronaut.context.ApplicationContextProvider,- io.micronaut.core.convert.ConversionServiceProvider,- MongoReactiveRepositoryOperations,- MongoReactorRepositoryOperations,- HintsCapableRepository,- ReactiveRepositoryOperations,- ReactorReactiveRepositoryOperations,- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>,- MethodContextAwareStoredQueryDecorator,- PreparedQueryDecorator
@RequiresReactiveMongo
@EachBean(com.mongodb.reactivestreams.client.MongoClient.class)
@Internal
public final class DefaultReactiveMongoRepositoryOperations
extends AbstractRepositoryOperations
implements MongoReactorRepositoryOperations, ReactorReactiveRepositoryOperations, ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
The reactive MongoDB repository operations implementation.
- Since:
- 3.3
- Author:
- Denis Stepanov
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static final class
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final MongoCollectionNameProviderprotected final MongoDatabaseNameProviderprotected static final org.bson.BsonDocumentFields inherited from class io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperationsattributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, runtimeEntityRegistry
- 
Method SummaryModifier and TypeMethodDescriptionprotected org.bson.BsonDocumentassociation(org.bson.codecs.configuration.CodecRegistry codecRegistry, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) protected <R> RconvertResult(org.bson.codecs.configuration.CodecRegistry codecRegistry, Class<R> resultType, org.bson.BsonDocument result, boolean isDtoProjection) <T> reactor.core.publisher.Mono<Long>count(PagedQuery<T> pagedQuery) Counts all results for the given query.protected final <T> org.bson.conversions.BsoncreateFilterIdAndVersion(RuntimePersistentEntity<T> persistentEntity, T entity, org.bson.codecs.configuration.CodecRegistry codecRegistry) <E,R> StoredQuery<E, R> decorate(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, R> storedQuery) Decorate stored query.<E,R> PreparedQuery<E, R> decorate(PreparedQuery<E, R> preparedQuery) Decorate prepared query.<T> reactor.core.publisher.Mono<Number>delete(DeleteOperation<T> operation) Deletes the entity.<T> reactor.core.publisher.Mono<Number>deleteAll(DeleteBatchOperation<T> operation) Deletes all the entities of the given type.reactor.core.publisher.Mono<Number>executeDelete(PreparedQuery<?, Number> preparedQuery) Executes a batch delete for the given query and parameter values.reactor.core.publisher.Mono<Number>executeUpdate(PreparedQuery<?, Number> preparedQuery) Executes an update for the given query and parameter values.<T> reactor.core.publisher.Mono<Boolean>exists(PreparedQuery<T, Boolean> preparedQuery) Check with an record exists for the given query.<T> reactor.core.publisher.Flux<T>findAll(PagedQuery<T> query) Finds all results for the given query.<T,R> reactor.core.publisher.Flux<R> findAll(PreparedQuery<T, R> preparedQuery) Finds all results for the given query.<T,R> reactor.core.publisher.Mono<R> findOne(PreparedQuery<T, R> preparedQuery) Find one by Query.<T> reactor.core.publisher.Mono<T>Find one by ID.<T,R> reactor.core.publisher.Mono<R> findOptional(PreparedQuery<T, R> preparedQuery) Find one by Query.<T> reactor.core.publisher.Mono<T>findOptional(Class<T> type, Object id) Find one by ID.<R> reactor.core.publisher.Mono<Page<R>>findPage(PagedQuery<R> pagedQuery) Find a page for the given entity and pageable.protected org.bson.codecs.configuration.CodecRegistrygetCodecRegistry(com.mongodb.reactivestreams.client.MongoDatabase mongoDatabase) protected com.mongodb.reactivestreams.client.MongoDatabasegetDatabase(PersistentEntity persistentEntity, Class<?> repository) protected final com.mongodb.client.model.DeleteOptionsgetDeleteOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected final com.mongodb.client.model.InsertManyOptionsgetInsertManyOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected final com.mongodb.client.model.InsertOneOptionsgetInsertOneOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected <E,R> MongoPreparedQuery<E, R> getMongoPreparedQuery(PreparedQuery<E, R> preparedQuery) protected <E,R> MongoStoredQuery<E, R> getMongoStoredQuery(StoredQuery<E, R> storedQuery) protected final com.mongodb.client.model.ReplaceOptionsgetReplaceOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected voidlogAggregate(MongoAggregation aggregation) protected void<T> reactor.core.publisher.Mono<T>persist(InsertOperation<T> operation) Persist the entity returning a possibly new entity.<T> reactor.core.publisher.Flux<T>persistAll(InsertBatchOperation<T> operation) Persist all the given entities.<T> reactor.core.publisher.Flux<T>persistBatch(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, Iterable<T> values, RuntimePersistentEntity<T> persistentEntity, Predicate<T> predicate) Persist multiple entities in batch during cascade.reactor.core.publisher.Mono<Void>persistManyAssociation(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) Persist JOIN table relationship.reactor.core.publisher.Mono<Void>persistManyAssociationBatch(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Iterable<Object> child, RuntimePersistentEntity<Object> childPersistentEntity, Predicate<Object> veto) Persist JOIN table relationships in batch.<T> reactor.core.publisher.Mono<T>persistOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Persist one entity during cascade.<T> reactor.core.publisher.Mono<T>update(UpdateOperation<T> operation) Updates the entity returning a possibly new entity.<T> reactor.core.publisher.Flux<T>updateAll(UpdateBatchOperation<T> operation) Updates the entities for the given operation.<T> reactor.core.publisher.Mono<T>updateOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Update one entity during cascade.<T> reactor.core.publisher.Mono<T>withClientSession(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Mono<T>> function) Starts a new session or reuses one from the context.<T> reactor.core.publisher.Flux<T>withClientSessionMany(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Flux<T>> function) Starts a new session or reuses one from the context.Methods inherited from class io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperationscheckOptimisticLocking, getApplicationContext, getConversionService, getEntity, getIdReader, isOnlySingleEndedJoins, triggerPostLoadMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.convert.ConversionServiceProvidergetConversionServiceMethods inherited from interface io.micronaut.data.operations.HintsCapableRepositorygetQueryHintsMethods inherited from interface io.micronaut.data.runtime.operations.internal.ReactiveCascadeOperations.ReactiveCascadeOperationsHelperisSupportsBatchDelete, isSupportsBatchInsert, isSupportsBatchUpdate
- 
Field Details- 
EMPTYprotected static final org.bson.BsonDocument EMPTY
- 
collectionNameProvider
- 
databaseNameProvider
 
- 
- 
Method Details- 
findOneDescription copied from interface:ReactiveRepositoryOperationsFind one by ID.- Specified by:
- findOnein interface- ReactiveRepositoryOperations
- Specified by:
- findOnein interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- type- The type
- id- The id
- Returns:
- A publisher that emits the result
 
- 
findOneDescription copied from interface:ReactiveRepositoryOperationsFind one by Query.- Specified by:
- findOnein interface- ReactiveRepositoryOperations
- Specified by:
- findOnein interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic resultType
- R- The result type
- Parameters:
- preparedQuery- The prepared query
- Returns:
- A publisher that emits the result
 
- 
existsDescription copied from interface:ReactiveRepositoryOperationsCheck with an record exists for the given query.- Specified by:
- existsin interface- ReactiveRepositoryOperations
- Specified by:
- existsin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The declaring type
- Parameters:
- preparedQuery- The query
- Returns:
- True if it exists
 
- 
findAllDescription copied from interface:ReactiveRepositoryOperationsFinds all results for the given query.- Specified by:
- findAllin interface- ReactiveRepositoryOperations
- Specified by:
- findAllin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- query- The paged query
- Returns:
- A publisher that emits the results
 
- 
countDescription copied from interface:ReactiveRepositoryOperationsCounts all results for the given query.- Specified by:
- countin interface- ReactiveRepositoryOperations
- Specified by:
- countin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- pagedQuery- The paged query
- Returns:
- A publisher that emits the count as a long
 
- 
findAllDescription copied from interface:ReactiveRepositoryOperationsFinds all results for the given query.- Specified by:
- findAllin interface- ReactiveRepositoryOperations
- Specified by:
- findAllin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The entity type
- R- The result type
- Parameters:
- preparedQuery- The prepared query
- Returns:
- A publisher that emits an iterable with all results
 
- 
findOptionalDescription copied from interface:ReactiveRepositoryOperationsFind one by ID.- Specified by:
- findOptionalin interface- ReactiveRepositoryOperations
- Specified by:
- findOptionalin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- type- The type
- id- The id
- Returns:
- A publisher that emits zero or one result
 
- 
findOptionalDescription copied from interface:ReactiveRepositoryOperationsFind one by Query.- Specified by:
- findOptionalin interface- ReactiveRepositoryOperations
- Specified by:
- findOptionalin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic resultType
- R- The result type
- Parameters:
- preparedQuery- The prepared query
- Returns:
- A publisher that emits the zero or one result
 
- 
findPageDescription copied from interface:ReactiveRepositoryOperationsFind a page for the given entity and pageable.- Specified by:
- findPagein interface- ReactiveRepositoryOperations
- Specified by:
- findPagein interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- R- The entity generic type
- Parameters:
- pagedQuery- The paged query
- Returns:
- The page type
 
- 
persistDescription copied from interface:ReactiveRepositoryOperationsPersist the entity returning a possibly new entity.- Specified by:
- persistin interface- ReactiveRepositoryOperations
- Specified by:
- persistin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The entity operation
- Returns:
- A publisher that emits the entity
 
- 
persistAllDescription copied from interface:ReactiveRepositoryOperationsPersist all the given entities.- Specified by:
- persistAllin interface- ReactiveRepositoryOperations
- Specified by:
- persistAllin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The batch operation
- Returns:
- The entities, possibly mutated
 
- 
updateDescription copied from interface:ReactiveRepositoryOperationsUpdates the entity returning a possibly new entity.- Specified by:
- updatein interface- ReactiveRepositoryOperations
- Specified by:
- updatein interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The entity operation
- Returns:
- A publisher that emits the entity
 
- 
updateAllDescription copied from interface:ReactiveRepositoryOperationsUpdates the entities for the given operation.- Specified by:
- updateAllin interface- ReactiveRepositoryOperations
- Specified by:
- updateAllin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The updated entities
 
- 
deleteDescription copied from interface:ReactiveRepositoryOperationsDeletes the entity.- Specified by:
- deletein interface- ReactiveRepositoryOperations
- Specified by:
- deletein interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The batch operation
- Returns:
- A publisher that emits the number of entities deleted
 
- 
deleteAllDescription copied from interface:ReactiveRepositoryOperationsDeletes all the entities of the given type.- Specified by:
- deleteAllin interface- ReactiveRepositoryOperations
- Specified by:
- deleteAllin interface- ReactorReactiveRepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The batch operation
- Returns:
- A publisher that emits the number of entities deleted
 
- 
executeUpdateDescription copied from interface:ReactiveRepositoryOperationsExecutes an update for the given query and parameter values. If it is possible to return the number of objects updated, then do so.- Specified by:
- executeUpdatein interface- ReactiveRepositoryOperations
- Specified by:
- executeUpdatein interface- ReactorReactiveRepositoryOperations
- Parameters:
- preparedQuery- The prepared query
- Returns:
- A publisher that emits a boolean true if the update was successful
 
- 
executeDeleteDescription copied from interface:ReactiveRepositoryOperationsExecutes a batch delete for the given query and parameter values. If it is possible to return the number of objects updated, then do so.- Specified by:
- executeDeletein interface- ReactiveRepositoryOperations
- Specified by:
- executeDeletein interface- ReactorReactiveRepositoryOperations
- Parameters:
- preparedQuery- The prepared query
- Returns:
- A publisher that emits a boolean true if the update was successful
 
- 
persistOnepublic <T> reactor.core.publisher.Mono<T> persistOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelperPersist one entity during cascade.- Specified by:
- persistOnein interface- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- value- The entity value
- persistentEntity- The persistent entity
- Returns:
- The entity value
 
- 
persistBatchpublic <T> reactor.core.publisher.Flux<T> persistBatch(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, Iterable<T> values, RuntimePersistentEntity<T> persistentEntity, Predicate<T> predicate) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelperPersist multiple entities in batch during cascade.- Specified by:
- persistBatchin interface- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- values- The entity values
- persistentEntity- The persistent entity
- predicate- The veto predicate
- Returns:
- The entity values
 
- 
updateOnepublic <T> reactor.core.publisher.Mono<T> updateOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelperUpdate one entity during cascade.- Specified by:
- updateOnein interface- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- value- The entity value
- persistentEntity- The persistent entity
- Returns:
- The entity value
 
- 
getDatabaseprotected com.mongodb.reactivestreams.client.MongoDatabase getDatabase(PersistentEntity persistentEntity, Class<?> repository) 
- 
getCodecRegistryprotected org.bson.codecs.configuration.CodecRegistry getCodecRegistry(com.mongodb.reactivestreams.client.MongoDatabase mongoDatabase) 
- 
persistManyAssociationpublic reactor.core.publisher.Mono<Void> persistManyAssociation(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelperPersist JOIN table relationship.- Specified by:
- persistManyAssociationin interface- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Parameters:
- ctx- The context
- runtimeAssociation- The association
- value- The parent entity value
- persistentEntity- The parent persistent entity
- child- The child entity value
- childPersistentEntity- The child persistent entity
- Returns:
- The empty mono
 
- 
persistManyAssociationBatchpublic reactor.core.publisher.Mono<Void> persistManyAssociationBatch(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Iterable<Object> child, RuntimePersistentEntity<Object> childPersistentEntity, Predicate<Object> veto) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelperPersist JOIN table relationships in batch.- Specified by:
- persistManyAssociationBatchin interface- ReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Parameters:
- ctx- The context
- runtimeAssociation- The association
- value- The parent entity value
- persistentEntity- The parent persistent entity
- child- The child entity values
- childPersistentEntity- The child persistent entity
- veto- The veto predicate
- Returns:
- The empty mono
 
- 
withClientSessionpublic <T> reactor.core.publisher.Mono<T> withClientSession(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Mono<T>> function) Description copied from interface:MongoReactorRepositoryOperationsStarts a new session or reuses one from the context.- Specified by:
- withClientSessionin interface- MongoReactorRepositoryOperations
- Type Parameters:
- T- The emitted type
- Parameters:
- function- The function
- Returns:
- The processed publisher
 
- 
withClientSessionManypublic <T> reactor.core.publisher.Flux<T> withClientSessionMany(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Flux<T>> function) Description copied from interface:MongoReactorRepositoryOperationsStarts a new session or reuses one from the context.- Specified by:
- withClientSessionManyin interface- MongoReactorRepositoryOperations
- Type Parameters:
- T- The emitted type
- Parameters:
- function- The function
- Returns:
- The processed publisher
 
- 
getReplaceOptionsprotected final com.mongodb.client.model.ReplaceOptions getReplaceOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) 
- 
getInsertOneOptionsprotected final com.mongodb.client.model.InsertOneOptions getInsertOneOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) 
- 
getInsertManyOptionsprotected final com.mongodb.client.model.InsertManyOptions getInsertManyOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) 
- 
getDeleteOptionsprotected final com.mongodb.client.model.DeleteOptions getDeleteOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) 
- 
getMongoStoredQuery
- 
getMongoPreparedQuery
- 
decorateDescription copied from interface:PreparedQueryDecoratorDecorate prepared query.- Specified by:
- decoratein interface- PreparedQueryDecorator
- Type Parameters:
- E- The entity type
- R- The result type
- Parameters:
- preparedQuery- The query to be decorated
- Returns:
- decorated prepared query
 
- 
decoratepublic <E,R> StoredQuery<E,R> decorate(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, R> storedQuery) Description copied from interface:MethodContextAwareStoredQueryDecoratorDecorate stored query.- Specified by:
- decoratein interface- MethodContextAwareStoredQueryDecorator
- Type Parameters:
- E- The entity type
- R- The result type
- Parameters:
- context- The context
- storedQuery- The query to be decorated
- Returns:
- decorated stored query
 
- 
convertResultprotected <R> R convertResult(org.bson.codecs.configuration.CodecRegistry codecRegistry, Class<R> resultType, org.bson.BsonDocument result, boolean isDtoProjection) 
- 
associationprotected org.bson.BsonDocument association(org.bson.codecs.configuration.CodecRegistry codecRegistry, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) 
- 
createFilterIdAndVersionprotected final <T> org.bson.conversions.Bson createFilterIdAndVersion(RuntimePersistentEntity<T> persistentEntity, T entity, org.bson.codecs.configuration.CodecRegistry codecRegistry) 
- 
logFind
- 
logAggregate
 
-