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 Summary
Modifier and TypeClassDescriptionprotected static final class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final MongoCollectionNameProvider
protected final MongoDatabaseNameProvider
protected static final org.bson.BsonDocument
Fields inherited from class io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperations
attributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, runtimeEntityRegistry
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.bson.BsonDocument
association
(org.bson.codecs.configuration.CodecRegistry codecRegistry, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) protected <R> R
convertResult
(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.Bson
createFilterIdAndVersion
(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.CodecRegistry
getCodecRegistry
(com.mongodb.reactivestreams.client.MongoDatabase mongoDatabase) protected com.mongodb.reactivestreams.client.MongoDatabase
getDatabase
(PersistentEntity persistentEntity, Class<?> repository) protected final com.mongodb.client.model.DeleteOptions
getDeleteOptions
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected final com.mongodb.client.model.InsertManyOptions
getInsertManyOptions
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected final com.mongodb.client.model.InsertOneOptions
getInsertOneOptions
(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.ReplaceOptions
getReplaceOptions
(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected void
logAggregate
(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.AbstractRepositoryOperations
checkOptimisticLocking, getApplicationContext, getConversionService, getEntity, getIdReader, isOnlySingleEndedJoins, triggerPostLoad
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.convert.ConversionServiceProvider
getConversionService
Methods inherited from interface io.micronaut.data.operations.HintsCapableRepository
getQueryHints
Methods inherited from interface io.micronaut.data.runtime.operations.internal.ReactiveCascadeOperations.ReactiveCascadeOperationsHelper
isSupportsBatchDelete, isSupportsBatchInsert, isSupportsBatchUpdate
-
Field Details
-
EMPTY
protected static final org.bson.BsonDocument EMPTY -
collectionNameProvider
-
databaseNameProvider
-
-
Method Details
-
findOne
Description copied from interface:ReactiveRepositoryOperations
Find one by ID.- Specified by:
findOne
in interfaceReactiveRepositoryOperations
- Specified by:
findOne
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
type
- The typeid
- The id- Returns:
- A publisher that emits the result
-
findOne
Description copied from interface:ReactiveRepositoryOperations
Find one by Query.- Specified by:
findOne
in interfaceReactiveRepositoryOperations
- Specified by:
findOne
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic resultTypeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits the result
-
exists
Description copied from interface:ReactiveRepositoryOperations
Check with an record exists for the given query.- Specified by:
exists
in interfaceReactiveRepositoryOperations
- Specified by:
exists
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The declaring type- Parameters:
preparedQuery
- The query- Returns:
- True if it exists
-
findAll
Description copied from interface:ReactiveRepositoryOperations
Finds all results for the given query.- Specified by:
findAll
in interfaceReactiveRepositoryOperations
- Specified by:
findAll
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
query
- The paged query- Returns:
- A publisher that emits the results
-
count
Description copied from interface:ReactiveRepositoryOperations
Counts all results for the given query.- Specified by:
count
in interfaceReactiveRepositoryOperations
- Specified by:
count
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
pagedQuery
- The paged query- Returns:
- A publisher that emits the count as a long
-
findAll
Description copied from interface:ReactiveRepositoryOperations
Finds all results for the given query.- Specified by:
findAll
in interfaceReactiveRepositoryOperations
- Specified by:
findAll
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The entity typeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits an iterable with all results
-
findOptional
Description copied from interface:ReactiveRepositoryOperations
Find one by ID.- Specified by:
findOptional
in interfaceReactiveRepositoryOperations
- Specified by:
findOptional
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
type
- The typeid
- The id- Returns:
- A publisher that emits zero or one result
-
findOptional
Description copied from interface:ReactiveRepositoryOperations
Find one by Query.- Specified by:
findOptional
in interfaceReactiveRepositoryOperations
- Specified by:
findOptional
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic resultTypeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits the zero or one result
-
findPage
Description copied from interface:ReactiveRepositoryOperations
Find a page for the given entity and pageable.- Specified by:
findPage
in interfaceReactiveRepositoryOperations
- Specified by:
findPage
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
R
- The entity generic type- Parameters:
pagedQuery
- The paged query- Returns:
- The page type
-
persist
Description copied from interface:ReactiveRepositoryOperations
Persist the entity returning a possibly new entity.- Specified by:
persist
in interfaceReactiveRepositoryOperations
- Specified by:
persist
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The entity operation- Returns:
- A publisher that emits the entity
-
persistAll
Description copied from interface:ReactiveRepositoryOperations
Persist all the given entities.- Specified by:
persistAll
in interfaceReactiveRepositoryOperations
- Specified by:
persistAll
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- The entities, possibly mutated
-
update
Description copied from interface:ReactiveRepositoryOperations
Updates the entity returning a possibly new entity.- Specified by:
update
in interfaceReactiveRepositoryOperations
- Specified by:
update
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The entity operation- Returns:
- A publisher that emits the entity
-
updateAll
Description copied from interface:ReactiveRepositoryOperations
Updates the entities for the given operation.- Specified by:
updateAll
in interfaceReactiveRepositoryOperations
- Specified by:
updateAll
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The updated entities
-
delete
Description copied from interface:ReactiveRepositoryOperations
Deletes the entity.- Specified by:
delete
in interfaceReactiveRepositoryOperations
- Specified by:
delete
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- A publisher that emits the number of entities deleted
-
deleteAll
Description copied from interface:ReactiveRepositoryOperations
Deletes all the entities of the given type.- Specified by:
deleteAll
in interfaceReactiveRepositoryOperations
- Specified by:
deleteAll
in interfaceReactorReactiveRepositoryOperations
- Type Parameters:
T
- The generic type- Parameters:
operation
- The batch operation- Returns:
- A publisher that emits the number of entities deleted
-
executeUpdate
Description copied from interface:ReactiveRepositoryOperations
Executes 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:
executeUpdate
in interfaceReactiveRepositoryOperations
- Specified by:
executeUpdate
in interfaceReactorReactiveRepositoryOperations
- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits a boolean true if the update was successful
-
executeDelete
Description copied from interface:ReactiveRepositoryOperations
Executes 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:
executeDelete
in interfaceReactiveRepositoryOperations
- Specified by:
executeDelete
in interfaceReactorReactiveRepositoryOperations
- Parameters:
preparedQuery
- The prepared query- Returns:
- A publisher that emits a boolean true if the update was successful
-
persistOne
public <T> reactor.core.publisher.Mono<T> persistOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelper
Persist one entity during cascade.- Specified by:
persistOne
in interfaceReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
T
- The entity type- Parameters:
ctx
- The contextvalue
- The entity valuepersistentEntity
- The persistent entity- Returns:
- The entity value
-
persistBatch
public <T> reactor.core.publisher.Flux<T> persistBatch(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, Iterable<T> values, RuntimePersistentEntity<T> persistentEntity, Predicate<T> predicate) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelper
Persist multiple entities in batch during cascade.- Specified by:
persistBatch
in interfaceReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
T
- The entity type- Parameters:
ctx
- The contextvalues
- The entity valuespersistentEntity
- The persistent entitypredicate
- The veto predicate- Returns:
- The entity values
-
updateOne
public <T> reactor.core.publisher.Mono<T> updateOne(DefaultReactiveMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:ReactiveCascadeOperations.ReactiveCascadeOperationsHelper
Update one entity during cascade.- Specified by:
updateOne
in interfaceReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Type Parameters:
T
- The entity type- Parameters:
ctx
- The contextvalue
- The entity valuepersistentEntity
- The persistent entity- Returns:
- The entity value
-
getDatabase
protected com.mongodb.reactivestreams.client.MongoDatabase getDatabase(PersistentEntity persistentEntity, Class<?> repository) -
getCodecRegistry
protected org.bson.codecs.configuration.CodecRegistry getCodecRegistry(com.mongodb.reactivestreams.client.MongoDatabase mongoDatabase) -
persistManyAssociation
public 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.ReactiveCascadeOperationsHelper
Persist JOIN table relationship.- Specified by:
persistManyAssociation
in interfaceReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Parameters:
ctx
- The contextruntimeAssociation
- The associationvalue
- The parent entity valuepersistentEntity
- The parent persistent entitychild
- The child entity valuechildPersistentEntity
- The child persistent entity- Returns:
- The empty mono
-
persistManyAssociationBatch
public 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.ReactiveCascadeOperationsHelper
Persist JOIN table relationships in batch.- Specified by:
persistManyAssociationBatch
in interfaceReactiveCascadeOperations.ReactiveCascadeOperationsHelper<DefaultReactiveMongoRepositoryOperations.MongoOperationContext>
- Parameters:
ctx
- The contextruntimeAssociation
- The associationvalue
- The parent entity valuepersistentEntity
- The parent persistent entitychild
- The child entity valueschildPersistentEntity
- The child persistent entityveto
- The veto predicate- Returns:
- The empty mono
-
withClientSession
public <T> reactor.core.publisher.Mono<T> withClientSession(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Mono<T>> function) Description copied from interface:MongoReactorRepositoryOperations
Starts a new session or reuses one from the context.- Specified by:
withClientSession
in interfaceMongoReactorRepositoryOperations
- Type Parameters:
T
- The emitted type- Parameters:
function
- The function- Returns:
- The processed publisher
-
withClientSessionMany
public <T> reactor.core.publisher.Flux<T> withClientSessionMany(Function<com.mongodb.reactivestreams.client.ClientSession, reactor.core.publisher.Flux<T>> function) Description copied from interface:MongoReactorRepositoryOperations
Starts a new session or reuses one from the context.- Specified by:
withClientSessionMany
in interfaceMongoReactorRepositoryOperations
- Type Parameters:
T
- The emitted type- Parameters:
function
- The function- Returns:
- The processed publisher
-
getReplaceOptions
protected final com.mongodb.client.model.ReplaceOptions getReplaceOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
getInsertOneOptions
protected final com.mongodb.client.model.InsertOneOptions getInsertOneOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
getInsertManyOptions
protected final com.mongodb.client.model.InsertManyOptions getInsertManyOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
getDeleteOptions
protected final com.mongodb.client.model.DeleteOptions getDeleteOptions(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) -
getMongoStoredQuery
-
getMongoPreparedQuery
-
decorate
Description copied from interface:PreparedQueryDecorator
Decorate prepared query.- Specified by:
decorate
in interfacePreparedQueryDecorator
- Type Parameters:
E
- The entity typeR
- The result type- Parameters:
preparedQuery
- The query to be decorated- Returns:
- decorated prepared query
-
decorate
public <E,R> StoredQuery<E,R> decorate(io.micronaut.aop.MethodInvocationContext<?, ?> context, StoredQuery<E, R> storedQuery) Description copied from interface:MethodContextAwareStoredQueryDecorator
Decorate stored query.- Specified by:
decorate
in interfaceMethodContextAwareStoredQueryDecorator
- Type Parameters:
E
- The entity typeR
- The result type- Parameters:
context
- The contextstoredQuery
- The query to be decorated- Returns:
- decorated stored query
-
convertResult
protected <R> R convertResult(org.bson.codecs.configuration.CodecRegistry codecRegistry, Class<R> resultType, org.bson.BsonDocument result, boolean isDtoProjection) -
association
protected org.bson.BsonDocument association(org.bson.codecs.configuration.CodecRegistry codecRegistry, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) -
createFilterIdAndVersion
protected final <T> org.bson.conversions.Bson createFilterIdAndVersion(RuntimePersistentEntity<T> persistentEntity, T entity, org.bson.codecs.configuration.CodecRegistry codecRegistry) -
logFind
-
logAggregate
-