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 QueryMethod
Mongo specific implementation of QueryMethod.
Author:
Oliver Gierke, Christoph Strobl, Mark Paluch, Jorge Rodríguez
  • Constructor Details

  • Method Details

    • createParameters

      protected MongoParameters createParameters(Method method)
      Overrides:
      createParameters in class QueryMethod
    • hasAnnotatedQuery

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

      public MongoEntityMetadata<?> getEntityInformation()
      Overrides:
      getEntityInformation in class QueryMethod
    • getDomainClass

      protected Class<?> getDomainClass()
      Overrides:
      getDomainClass in class QueryMethod
    • getParameters

      public MongoParameters getParameters()
      Overrides:
      getParameters in class 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 a non-empty Query.sort().
      Returns:
      true if method annotated with Query having a 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
    • hasAnnotatedReadPreference

      public boolean hasAnnotatedReadPreference()
      Check if the query method is decorated with a non-empty ReadPreference.
      Returns:
      true if method annotated with Query or Aggregation having a non-empty collation attribute.
      Since:
      4.2
    • getAnnotatedReadPreference

      public String getAnnotatedReadPreference()
      Get the ReadPreference extracted from the ReadPreference annotation.
      Returns:
      the name of the ReadPreference.
      Throws:
      IllegalStateException - if method not annotated with Query. Make sure to check hasAnnotatedReadPreference() first.
      Since:
      4.2
    • hasAnnotatedCollation

      public boolean hasAnnotatedCollation()
      Check if the query method is decorated with a non-empty Query.collation() 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 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 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