Class QueryMethod

java.lang.Object
org.springframework.data.repository.query.QueryMethod

public class QueryMethod extends Object
Abstraction of a method that is designated to execute a finder query. Enriches the standard Method interface with specific information that is necessary to construct RepositoryQuerys for the method.
Author:
Oliver Gierke, Thomas Darimont, Christoph Strobl, Maciek Opała, Mark Paluch, Johannes Englmeier
  • Constructor Details

    • QueryMethod

      public QueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory)
      Creates a new QueryMethod from the given parameters. Looks up the correct query to use for following invocations of the method given.
      Parameters:
      method - must not be null.
      metadata - must not be null.
      factory - must not be null.
  • Method Details

    • createParameters

      protected Parameters<?,?> createParameters(Method method)
      Creates a Parameters instance.
      Parameters:
      method -
      Returns:
      must not return null.
    • getName

      public String getName()
      Returns the method's name.
      Returns:
    • getEntityInformation

      public EntityMetadata<?> getEntityInformation()
    • getNamedQueryName

      public String getNamedQueryName()
      Returns the name of the named query this method belongs to.
      Returns:
    • getDomainClass

      protected Class<?> getDomainClass()
      Returns the domain class the query method is targeted at.
      Returns:
      will never be null.
    • getReturnedObjectType

      public Class<?> getReturnedObjectType()
      Returns the type of the object that will be returned.
      Returns:
    • isCollectionQuery

      public boolean isCollectionQuery()
      Returns whether the finder will actually return a collection of entities or a single one.
      Returns:
    • isSliceQuery

      public boolean isSliceQuery()
      Returns whether the query method will return a Slice.
      Returns:
      Since:
      1.8
    • isPageQuery

      public final boolean isPageQuery()
      Returns whether the finder will return a Page of results.
      Returns:
    • isModifyingQuery

      public boolean isModifyingQuery()
      Returns whether the query method is a modifying one.
      Returns:
    • isQueryForEntity

      public boolean isQueryForEntity()
      Returns whether the query for this method actually returns entities.
      Returns:
    • isStreamQuery

      public boolean isStreamQuery()
      Returns whether the method returns a Stream.
      Returns:
      Since:
      1.10
    • getParameters

      public Parameters<?,?> getParameters()
      Returns the Parameters wrapper to gain additional information about Method parameters.
      Returns:
    • getResultProcessor

      public ResultProcessor getResultProcessor()
      Returns the ResultProcessor to be used with the query method.
      Returns:
      the resultFactory
    • toString

      public String toString()
      Overrides:
      toString in class Object