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
ConstructorsConstructorDescriptionMongoQueryMethod(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 newMongoQueryMethodfrom the givenMethod. -
Method Summary
Modifier and TypeMethodDescriptionprotected MongoParameterscreateParameters(Method method) String[]Returns the aggregation pipeline declared in aAggregationannotation.Get the collation value extracted from theQueryorAggregationannotation.Returns the aggregation pipeline declared via aHintannotation.Get the sort value, used as default, extracted from theQueryannotation.protected Class<?>Returns theMetaattributes to be applied.booleanReturns whether the method has an annotated query.booleanCheck if the query method is decorated with an non emptyQuery.collation()or orAggregation.collation().booleanbooleanReturns whether the method has an annotated query.booleanCheck if the query method is decorated with an non emptyQuery.sort().booleanbooleanbooleanReturns whether the query is a geo near query.booleanvoidverify()Verify the actualQueryMethodis 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 newMongoQueryMethodfrom 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:
createParametersin classorg.springframework.data.repository.query.QueryMethod
-
hasAnnotatedQuery
public boolean hasAnnotatedQuery()Returns whether the method has an annotated query.- Returns:
-
getEntityInformation
- Overrides:
getEntityInformationin classorg.springframework.data.repository.query.QueryMethod
-
getDomainClass
- Overrides:
getDomainClassin classorg.springframework.data.repository.query.QueryMethod
-
getParameters
- Overrides:
getParametersin 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
Metaannotation is available. - Since:
- 1.6
-
getQueryMetaAttributes
Returns theMetaattributes 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
Queryhaving an non empty sort attribute. - Since:
- 2.1
-
getAnnotatedSort
Get the sort value, used as default, extracted from theQueryannotation.- 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
QueryorAggregationhaving a non-empty collation attribute. - Since:
- 2.2
-
getAnnotatedCollation
Get the collation value extracted from theQueryorAggregationannotation.- Returns:
- the
Query.collation()or orAggregation.collation()value. - Throws:
IllegalStateException- if method not annotated withQueryorAggregation. Make sure to checkhasAnnotatedQuery()first.- Since:
- 2.2
-
hasAnnotatedAggregation
public boolean hasAnnotatedAggregation()Returns whether the method has an annotated query.- Returns:
- true if
Aggregationis present. - Since:
- 2.2
-
getAnnotatedAggregation
Returns the aggregation pipeline declared in aAggregationannotation.- 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
Hintannotation is present and the index name is not empty. - Since:
- 4.1
-
getAnnotatedHint
Returns the aggregation pipeline declared via aHintannotation.- Returns:
- the index name (might be empty).
- Throws:
IllegalStateException- if the method is not annotated withHint- Since:
- 4.1
-
isModifyingQuery
public boolean isModifyingQuery()- Overrides:
isModifyingQueryin classorg.springframework.data.repository.query.QueryMethod
-
hasAnnotatedUpdate
public boolean hasAnnotatedUpdate()- Returns:
- true if
Updateannotation is present. - Since:
- 3.4
-
getUpdateSource
- Returns:
- the
Updateor null if not present. - Since:
- 3.4
-
verify
public void verify()Verify the actualQueryMethodis valid in terms of supported return and parameter types.- Throws:
IllegalStateException- Since:
- 3.4
-