org.springframework.data.mongodb.repository

Annotation Type Query

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element and Description
      boolean count
      Returns whether the query defined should be executed as count projection.
      boolean delete
      Returns whether the query should delete matching documents.
      boolean exists
      Returns whether the query defined should be executed as exists projection.
      String fields
      Defines the fields that should be returned for the given query.
      String sort
      Defines a default sort order for the given query.
      String value
      Takes a MongoDB JSON string to define the actual query to be executed.
    • Element Detail

      • value

        public abstract String value
        Takes a MongoDB JSON string to define the actual query to be executed. This one will take precedence over the method name then.
        Returns:
        Default:
        ""
      • fields

        public abstract String fields
        Defines the fields that should be returned for the given query. Note that only these fields will make it into the domain object returned.
        Returns:
        Default:
        ""
      • count

        public abstract boolean count
        Returns whether the query defined should be executed as count projection.
        Returns:
        Since:
        1.3
        Default:
        false
      • exists

        public abstract boolean exists
        Returns whether the query defined should be executed as exists projection.
        Returns:
        Since:
        1.10
        Default:
        false
      • delete

        public abstract boolean delete
        Returns whether the query should delete matching documents.
        Returns:
        Since:
        1.5
        Default:
        false
      • sort

        public abstract String sort
        Defines a default sort order for the given query.
        NOTE: The so set defaults can be altered / overwritten using an explicit Sort argument of the query method.
         
        
                        @Query(sort = "{ age : -1 }") // order by age descending
                        List findByFirstname(String firstname);
         
         
        Returns:
        Since:
        2.1
        Default:
        ""