Class MongoQueryMethod
java.lang.Object
org.springframework.data.repository.query.QueryMethod
org.springframework.data.mongodb.repository.query.MongoQueryMethod
- Direct Known Subclasses:
ReactiveMongoQueryMethod
Mongo specific implementation of
QueryMethod
.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch, Jorge RodrÃguez
-
Constructor Summary
ConstructorDescriptionMongoQueryMethod
(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) Creates a newMongoQueryMethod
from the givenMethod
. -
Method Summary
Modifier and TypeMethodDescriptionprotected MongoParameters
createParameters
(ParametersSource parametersSource) String[]
Returns the aggregation pipeline declared in aAggregation
annotation.Get the collation value extracted from theQuery
orAggregation
annotation.Returns the aggregation pipeline declared via aHint
annotation.Get theReadPreference
extracted from theReadPreference
annotation.Get the sort value, used as default, extracted from theQuery
annotation.protected Class<?>
Returns theMeta
attributes to be applied.boolean
Returns whether the method has an annotated query.boolean
Check if the query method is decorated with a non-emptyQuery.collation()
orAggregation.collation()
.boolean
boolean
Returns whether the method has an annotated query.boolean
Check if the query method is decorated with a non-emptyReadPreference
.boolean
Check if the query method is decorated with a non-emptyQuery.sort()
.boolean
boolean
boolean
Returns whether the query is a geo near query.boolean
void
verify()
Verify the actualQueryMethod
is valid in terms of supported return and parameter types.Methods inherited from class org.springframework.data.repository.query.QueryMethod
createParameters, getName, getNamedQueryName, getResultProcessor, getReturnedObjectType, isCollectionQuery, isPageQuery, isQueryForEntity, isScrollQuery, isSliceQuery, isStreamQuery, toString
-
Constructor Details
-
MongoQueryMethod
public MongoQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory projectionFactory, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) Creates a newMongoQueryMethod
from the givenMethod
.- Parameters:
method
- must not be null.metadata
- must not be null.projectionFactory
- must not be null.mappingContext
- must not be null.
-
-
Method Details
-
createParameters
- Overrides:
createParameters
in classQueryMethod
-
hasAnnotatedQuery
public boolean hasAnnotatedQuery()Returns whether the method has an annotated query.- Returns:
-
getEntityInformation
- Overrides:
getEntityInformation
in classQueryMethod
-
getDomainClass
- Overrides:
getDomainClass
in classQueryMethod
-
getParameters
- Overrides:
getParameters
in classQueryMethod
-
isGeoNearQuery
public boolean isGeoNearQuery()Returns whether the query is a geo near query.- Returns:
-
hasQueryMetaAttributes
public boolean hasQueryMetaAttributes()- Returns:
- return true if
Meta
annotation is available. - Since:
- 1.6
-
getQueryMetaAttributes
Returns theMeta
attributes to be applied.- Returns:
- never null.
- Since:
- 1.6
-
hasAnnotatedSort
public boolean hasAnnotatedSort()Check if the query method is decorated with a non-emptyQuery.sort()
.- Returns:
- true if method annotated with
Query
having a non-empty sort attribute. - Since:
- 2.1
-
getAnnotatedSort
Get the sort value, used as default, extracted from theQuery
annotation.- Returns:
- the
Query.sort()
value. - Throws:
IllegalStateException
- if method not annotated withQuery
. Make sure to checkhasAnnotatedQuery()
first.- Since:
- 2.1
-
hasAnnotatedReadPreference
public boolean hasAnnotatedReadPreference()Check if the query method is decorated with a non-emptyReadPreference
.- Returns:
- true if method annotated with
Query
orAggregation
having a non-empty collation attribute. - Since:
- 4.2
-
getAnnotatedReadPreference
Get theReadPreference
extracted from theReadPreference
annotation.- Returns:
- the name of the
ReadPreference
. - Throws:
IllegalStateException
- if method not annotated withQuery
. Make sure to checkhasAnnotatedReadPreference()
first.- Since:
- 4.2
-
hasAnnotatedCollation
public boolean hasAnnotatedCollation()Check if the query method is decorated with a non-emptyQuery.collation()
orAggregation.collation()
.- Returns:
- true if method annotated with
Query
orAggregation
having a non-empty collation attribute. - Since:
- 2.2
-
getAnnotatedCollation
Get the collation value extracted from theQuery
orAggregation
annotation.- Returns:
- the
Query.collation()
orAggregation.collation()
value. - Throws:
IllegalStateException
- if method not annotated withQuery
orAggregation
. Make sure to checkhasAnnotatedQuery()
first.- Since:
- 2.2
-
hasAnnotatedAggregation
public boolean hasAnnotatedAggregation()Returns whether the method has an annotated query.- Returns:
- true if
Aggregation
is present. - Since:
- 2.2
-
getAnnotatedAggregation
Returns the aggregation pipeline declared in aAggregation
annotation.- Returns:
- the aggregation pipeline.
- Throws:
IllegalStateException
- if method not annotated withAggregation
. Make sure to checkhasAnnotatedAggregation()
first.- Since:
- 2.2
-
hasAnnotatedHint
public boolean hasAnnotatedHint()- Returns:
- true if the
Hint
annotation is present and the index name is not empty. - Since:
- 4.1
-
getAnnotatedHint
Returns the aggregation pipeline declared via aHint
annotation.- Returns:
- the index name (might be empty).
- Throws:
IllegalStateException
- if the method is not annotated withHint
- Since:
- 4.1
-
isModifyingQuery
public boolean isModifyingQuery()- Overrides:
isModifyingQuery
in classQueryMethod
-
hasAnnotatedUpdate
public boolean hasAnnotatedUpdate()- Returns:
- true if
Update
annotation is present. - Since:
- 3.4
-
getUpdateSource
- Returns:
- the
Update
or null if not present. - Since:
- 3.4
-
verify
public void verify()Verify the actualQueryMethod
is valid in terms of supported return and parameter types.- Throws:
IllegalStateException
- Since:
- 3.4
-