Class AbstractReactiveMongoQuery
java.lang.Object
org.springframework.data.mongodb.repository.query.AbstractReactiveMongoQuery
- All Implemented Interfaces:
org.springframework.data.repository.query.RepositoryQuery
- Direct Known Subclasses:
ReactivePartTreeMongoQuery
,ReactiveStringBasedAggregation
,ReactiveStringBasedMongoQuery
public abstract class AbstractReactiveMongoQuery
extends Object
implements org.springframework.data.repository.query.RepositoryQuery
Base class for reactive
RepositoryQuery
implementations for MongoDB.- Since:
- 2.0
- Author:
- Mark Paluch, Christoph Strobl
-
Constructor Summary
ConstructorDescriptionAbstractReactiveMongoQuery
(ReactiveMongoQueryMethod method, ReactiveMongoOperations operations, org.springframework.expression.ExpressionParser expressionParser, org.springframework.data.repository.query.ReactiveQueryMethodEvaluationContextProvider evaluationContextProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected reactor.core.publisher.Mono<Query>
createCountQuery
(ConvertingParameterAccessor accessor) Creates aQuery
instance using the givenConvertingParameterAccessor
.protected abstract reactor.core.publisher.Mono<Query>
createQuery
(ConvertingParameterAccessor accessor) Creates aQuery
instance using the givenParameterAccessor
protected reactor.core.publisher.Mono<UpdateDefinition>
createUpdate
(MongoParameterAccessor accessor) protected org.reactivestreams.Publisher<Object>
doExecute
(ReactiveMongoQueryMethod method, org.springframework.data.repository.query.ResultProcessor processor, ConvertingParameterAccessor accessor, Class<?> typeToRead) Execute theRepositoryQuery
of the given method with the parameters provided by theaccessor
org.reactivestreams.Publisher<Object>
protected reactor.core.publisher.Mono<org.bson.codecs.configuration.CodecRegistry>
protected reactor.core.publisher.Mono<ParameterBindingDocumentCodec>
Obtain theParameterBindingDocumentCodec
used for parsing JSON expressions.protected reactor.core.publisher.Mono<org.springframework.data.mapping.model.SpELExpressionEvaluator>
getSpelEvaluatorFor
(org.springframework.data.spel.ExpressionDependencies dependencies, MongoParameterAccessor accessor) Obtain apublisher
emitting theSpELExpressionEvaluator
suitable to evaluate expressions backed by the given dependencies.protected abstract boolean
Returns whether the query should get a count projection applied.protected abstract boolean
Return weather the query should delete matching documents.protected abstract boolean
Returns whether the query should get an exists projection applied.protected abstract boolean
Return whether the query has an explicit limit set.protected reactor.core.publisher.Mono<List<AggregationOperation>>
parseAggregationPipeline
(String[] pipeline, MongoParameterAccessor accessor) Parse the given aggregation pipeline stages applying values to placeholders to compute the actual list ofoperations
.
-
Constructor Details
-
AbstractReactiveMongoQuery
public AbstractReactiveMongoQuery(ReactiveMongoQueryMethod method, ReactiveMongoOperations operations, org.springframework.expression.ExpressionParser expressionParser, org.springframework.data.repository.query.ReactiveQueryMethodEvaluationContextProvider evaluationContextProvider) - Parameters:
method
- must not be null.operations
- must not be null.expressionParser
- must not be null.evaluationContextProvider
- must not be null.
-
-
Method Details
-
getQueryMethod
- Specified by:
getQueryMethod
in interfaceorg.springframework.data.repository.query.RepositoryQuery
-
execute
- Specified by:
execute
in interfaceorg.springframework.data.repository.query.RepositoryQuery
-
doExecute
protected org.reactivestreams.Publisher<Object> doExecute(ReactiveMongoQueryMethod method, org.springframework.data.repository.query.ResultProcessor processor, ConvertingParameterAccessor accessor, @Nullable Class<?> typeToRead) Execute theRepositoryQuery
of the given method with the parameters provided by theaccessor
- Parameters:
method
- theReactiveMongoQueryMethod
invoked. Never null.processor
-ResultProcessor
for post procession. Never null.accessor
- for providing invocation arguments. Never null.typeToRead
- the desired component target type. Can be null.
-
createCountQuery
Creates aQuery
instance using the givenConvertingParameterAccessor
. Will delegate tocreateQuery(ConvertingParameterAccessor)
by default but allows customization of the count query to be triggered.- Parameters:
accessor
- must not be null.- Returns:
-
createUpdate
protected reactor.core.publisher.Mono<UpdateDefinition> createUpdate(MongoParameterAccessor accessor) Retrieves theupdate
from the givenaccessor
or creates one via by parsing the annotated statement extracted fromUpdate
.- Parameters:
accessor
- never null.- Returns:
- the computed
UpdateDefinition
. - Throws:
IllegalStateException
- if no update could be found.- Since:
- 3.4
-
parseAggregationPipeline
protected reactor.core.publisher.Mono<List<AggregationOperation>> parseAggregationPipeline(String[] pipeline, MongoParameterAccessor accessor) Parse the given aggregation pipeline stages applying values to placeholders to compute the actual list ofoperations
.- Parameters:
pipeline
- must not be null.accessor
- must not be null.- Returns:
- the parsed aggregation pipeline.
- Since:
- 3.4
-
getParameterBindingCodec
Obtain theParameterBindingDocumentCodec
used for parsing JSON expressions.- Returns:
- never null.
- Since:
- 3.4
-
getSpelEvaluatorFor
protected reactor.core.publisher.Mono<org.springframework.data.mapping.model.SpELExpressionEvaluator> getSpelEvaluatorFor(org.springframework.data.spel.ExpressionDependencies dependencies, MongoParameterAccessor accessor) Obtain apublisher
emitting theSpELExpressionEvaluator
suitable to evaluate expressions backed by the given dependencies.- Parameters:
dependencies
- must not be null.accessor
- must not be null.- Returns:
- a
Mono
emitting theSpELExpressionEvaluator
when ready. - Since:
- 3.4
-
getCodecRegistry
protected reactor.core.publisher.Mono<org.bson.codecs.configuration.CodecRegistry> getCodecRegistry()- Returns:
- a
Mono
emitting theCodecRegistry
when ready. - Since:
- 2.4
-
createQuery
protected abstract reactor.core.publisher.Mono<Query> createQuery(ConvertingParameterAccessor accessor) Creates aQuery
instance using the givenParameterAccessor
- Parameters:
accessor
- must not be null.- Returns:
-
isCountQuery
protected abstract boolean isCountQuery()Returns whether the query should get a count projection applied.- Returns:
-
isExistsQuery
protected abstract boolean isExistsQuery()Returns whether the query should get an exists projection applied.- Returns:
- Since:
- 2.0.9
-
isDeleteQuery
protected abstract boolean isDeleteQuery()Return weather the query should delete matching documents.- Returns:
- Since:
- 1.5
-
isLimiting
protected abstract boolean isLimiting()Return whether the query has an explicit limit set.- Returns:
- Since:
- 2.0.4
-