Class MongoQueryMethod
java.lang.Object
org.springframework.data.repository.query.QueryMethod
org.springframework.data.mongodb.repository.query.MongoQueryMethod
- Direct Known Subclasses:
ReactiveMongoQueryMethod
public class MongoQueryMethod
extends org.springframework.data.repository.query.QueryMethod
Mongo specific implementation of
QueryMethod
.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorDescriptionMongoQueryMethod
(Method method, org.springframework.data.repository.core.RepositoryMetadata metadata, org.springframework.data.projection.ProjectionFactory projectionFactory, org.springframework.data.mapping.context.MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext) Creates a newMongoQueryMethod
from the givenMethod
. -
Method Summary
Modifier and TypeMethodDescriptionprotected MongoParameters
createParameters
(Method method) 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 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 an non emptyQuery.collation()
or orAggregation.collation()
.boolean
boolean
Returns whether the method has an annotated query.boolean
Check if the query method is decorated with an 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, org.springframework.data.repository.core.RepositoryMetadata metadata, org.springframework.data.projection.ProjectionFactory projectionFactory, org.springframework.data.mapping.context.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 classorg.springframework.data.repository.query.QueryMethod
-
hasAnnotatedQuery
public boolean hasAnnotatedQuery()Returns whether the method has an annotated query.- Returns:
-
getEntityInformation
- Overrides:
getEntityInformation
in classorg.springframework.data.repository.query.QueryMethod
-
getDomainClass
- Overrides:
getDomainClass
in classorg.springframework.data.repository.query.QueryMethod
-
getParameters
- Overrides:
getParameters
in classorg.springframework.data.repository.query.QueryMethod
-
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 an non emptyQuery.sort()
.- Returns:
- true if method annotated with
Query
having an 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
-
hasAnnotatedCollation
public boolean hasAnnotatedCollation()Check if the query method is decorated with an non emptyQuery.collation()
or 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()
or 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 classorg.springframework.data.repository.query.QueryMethod
-
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
-