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 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 new MongoQueryMethod from the given Method.
      Parameters:
      method - must not be null.
      metadata - must not be null.
      projectionFactory - must not be null.
      mappingContext - must not be null.
  • Method Details

    • createParameters

      protected MongoParameters createParameters(Method method)
      Overrides:
      createParameters in class org.springframework.data.repository.query.QueryMethod
    • hasAnnotatedQuery

      public boolean hasAnnotatedQuery()
      Returns whether the method has an annotated query.
      Returns:
    • getEntityInformation

      public MongoEntityMetadata<?> getEntityInformation()
      Overrides:
      getEntityInformation in class org.springframework.data.repository.query.QueryMethod
    • getDomainClass

      protected Class<?> getDomainClass()
      Overrides:
      getDomainClass in class org.springframework.data.repository.query.QueryMethod
    • getParameters

      public MongoParameters getParameters()
      Overrides:
      getParameters in class org.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

      public Meta getQueryMetaAttributes()
      Returns the Meta attributes to be applied.
      Returns:
      never null.
      Since:
      1.6
    • hasAnnotatedSort

      public boolean hasAnnotatedSort()
      Check if the query method is decorated with an non empty Query.sort().
      Returns:
      true if method annotated with Query having an non empty sort attribute.
      Since:
      2.1
    • getAnnotatedSort

      public String getAnnotatedSort()
      Get the sort value, used as default, extracted from the Query annotation.
      Returns:
      the Query.sort() value.
      Throws:
      IllegalStateException - if method not annotated with Query. Make sure to check hasAnnotatedQuery() first.
      Since:
      2.1
    • hasAnnotatedCollation

      public boolean hasAnnotatedCollation()
      Check if the query method is decorated with an non empty Query.collation() or or Aggregation.collation().
      Returns:
      true if method annotated with Query or Aggregation having a non-empty collation attribute.
      Since:
      2.2
    • getAnnotatedCollation

      public String getAnnotatedCollation()
      Get the collation value extracted from the Query or Aggregation annotation.
      Returns:
      the Query.collation() or or Aggregation.collation() value.
      Throws:
      IllegalStateException - if method not annotated with Query or Aggregation. Make sure to check hasAnnotatedQuery() 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

      public String[] getAnnotatedAggregation()
      Returns the aggregation pipeline declared in a Aggregation annotation.
      Returns:
      the aggregation pipeline.
      Throws:
      IllegalStateException - if method not annotated with Aggregation. Make sure to check hasAnnotatedAggregation() 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

      public String getAnnotatedHint()
      Returns the aggregation pipeline declared via a Hint annotation.
      Returns:
      the index name (might be empty).
      Throws:
      IllegalStateException - if the method is not annotated with Hint
      Since:
      4.1
    • isModifyingQuery

      public boolean isModifyingQuery()
      Overrides:
      isModifyingQuery in class org.springframework.data.repository.query.QueryMethod
    • hasAnnotatedUpdate

      public boolean hasAnnotatedUpdate()
      Returns:
      true if Update annotation is present.
      Since:
      3.4
    • getUpdateSource

      public Update getUpdateSource()
      Returns:
      the Update or null if not present.
      Since:
      3.4
    • verify

      public void verify()
      Verify the actual QueryMethod is valid in terms of supported return and parameter types.
      Throws:
      IllegalStateException
      Since:
      3.4